Submission #65018031
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#ifndef _Alignof
#define _Alignof __alignof__
#endif
#include <bits/stdc++.h>
#include <numeric>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
#define yes "Yes"
#define no "No"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
const vector<char> alpha = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
const ll INF = 1e18;
struct Chord {
int a, b;
};
struct Fenw {
int n;
vector<ll> fenw;
Fenw(int n) : n(n), fenw(n+1,0) { }
void update(int i, ll delta) {
for(; i <= n; i += i & -i)
fenw[i] += delta;
}
ll query(int i) {
ll s = 0;
for(; i; i -= i & -i)
s += fenw[i];
return s;
}
ll query(int l, int r) {
return query(r) - query(l-1);
}
};
int main(){
int N, M;
cin >> N >> M;
vector<Chord> chords(M);
REP(i,M){
int a, b;
cin >> a >> b;
if(a > b) swap(a,b);
chords[i] = {a, b};
}
// ソート:aが小さい順
sort(chords.begin(), chords.end(), [](const Chord &c1, const Chord &c2){
return c1.a < c2.a;
});
Fenw fenw(N);
ll ans = 0;
for (auto &c : chords) {
if(c.a + 1 <= c.b - 1){
ans += fenw.query(c.a+1, c.b-1);
}
fenw.update(c.b,1);
}
cout << ans << "\n";
}
Submission Info
| Submission Time |
|
| Task |
D - Line Crossing |
| User |
una_o0 |
| Language |
C++ 17 (gcc 12.2) |
| Score |
0 |
| Code Size |
1851 Byte |
| Status |
WA |
| Exec Time |
139 ms |
| Memory |
13436 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
0 / 400 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_00.txt, 00_sample_01.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
WA |
1 ms |
3528 KiB |
| 00_sample_01.txt |
WA |
1 ms |
3536 KiB |
| 01_test_00.txt |
WA |
1 ms |
3700 KiB |
| 01_test_01.txt |
WA |
19 ms |
3824 KiB |
| 01_test_02.txt |
WA |
2 ms |
3588 KiB |
| 01_test_03.txt |
WA |
22 ms |
3604 KiB |
| 01_test_04.txt |
WA |
1 ms |
3624 KiB |
| 01_test_05.txt |
WA |
36 ms |
10188 KiB |
| 01_test_06.txt |
WA |
139 ms |
12800 KiB |
| 01_test_07.txt |
WA |
132 ms |
7836 KiB |
| 01_test_08.txt |
WA |
1 ms |
3680 KiB |
| 01_test_09.txt |
WA |
23 ms |
7896 KiB |
| 01_test_10.txt |
WA |
139 ms |
11340 KiB |
| 01_test_11.txt |
WA |
44 ms |
9716 KiB |
| 01_test_12.txt |
WA |
4 ms |
10996 KiB |
| 01_test_13.txt |
WA |
125 ms |
13236 KiB |
| 01_test_14.txt |
WA |
138 ms |
13436 KiB |
| 01_test_15.txt |
WA |
66 ms |
12060 KiB |
| 01_test_16.txt |
WA |
4 ms |
11000 KiB |
| 01_test_17.txt |
WA |
115 ms |
13068 KiB |
| 01_test_18.txt |
WA |
39 ms |
9564 KiB |
| 01_test_19.txt |
WA |
40 ms |
7324 KiB |
| 01_test_20.txt |
WA |
68 ms |
5604 KiB |
| 01_test_21.txt |
WA |
76 ms |
12208 KiB |
| 01_test_22.txt |
WA |
63 ms |
12100 KiB |
| 01_test_23.txt |
AC |
70 ms |
7132 KiB |
| 01_test_24.txt |
AC |
10 ms |
10292 KiB |
| 01_test_25.txt |
AC |
84 ms |
7928 KiB |
| 01_test_26.txt |
AC |
13 ms |
11056 KiB |
| 01_test_27.txt |
AC |
102 ms |
12676 KiB |
| 01_test_28.txt |
AC |
1 ms |
3488 KiB |
| 01_test_29.txt |
WA |
1 ms |
3492 KiB |
| 01_test_30.txt |
WA |
1 ms |
3608 KiB |
| 01_test_31.txt |
WA |
78 ms |
5548 KiB |