# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
296203 | 2020-09-10T11:58:25 Z | maximath_1 | Monochrome Points (JOI20_monochrome) | C++11 | 18 ms | 3604 KB |
#include <iostream> #include <array> #include <vector> #include <algorithm> #include <string.h> #include <set> #include <math.h> #include <numeric> #include <assert.h> #include <map> #include <unordered_map> #include <unordered_set> #include <iomanip> #include <bitset> #include <queue> #include <random> #include <chrono> #include <limits.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define ld long double #define endl "\n" typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> OST; typedef tree<pair<int, int>, null_type, less_equal<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> OST_multiset; mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); const ll inf = 1e9 + 69; const ld pi = 3.14159265358979323L; const ld eps = 1e-15; void setIn(string s){freopen(s.c_str(), "r", stdin);} void setOut(string s){freopen(s.c_str(), "w", stdout);} void unsyncIO(){cin.tie(0) -> sync_with_stdio(0);} int setIO_count = 0; void setIO(string s = "", bool inx = 0, bool outx = 0){ if(!setIO_count){ unsyncIO(); setIO_count = 1; } if(s.size()){ //output only if(inx) setIn(s + ".in"); if(outx) setOut(s + ".out"); } } #define gc getchar//_unlocked //can't for window server #define pc putchar//_unlocked //can't for window server ll inp(){ char c = gc(); bool neg = false; for(; c < '0'||'9' < c; c = gc()) if(c == '-') neg=true; ll rs = c - '0'; c = gc(); for(; '0' <= c && c <= '9'; c = gc()) rs = (rs << 1) + (rs << 3) + (c - '0'); if(neg) rs = -rs; return rs; } void pri(ll _n){ ll N = _n, rev, count = 0; bool neg = false; if(N < 0){ N = -N; neg = true; } rev = N; if(N == 0) {pc('0'); return;} if(neg) pc('-'); while(rev % 10 == 0) {count ++; rev /= 10;} rev = 0; while(N != 0) {rev = (rev << 3) + (rev << 1) + N % 10; N /= 10;} while(rev != 0) {pc(rev % 10 + '0'); rev /= 10;} while(count --) pc('0'); } const ll mod = 1e9 + 7; const int N = 200005; int n, v[N * 2], pref[N]; string s; int main(){ setIO(); cin >> n >> s; for(int i = 0; i < 2 * n; i ++) v[i] = (s[i] == 'W' ? 1 : -1); for(int i = 0; i < n; i ++){ if(i == 0) pref[i] = v[i] * (v[i] == v[n + i]); else pref[i] = pref[i - 1] + v[i] * (v[i] == v[n + i]); } sort(pref, pref + n); ll ans = n * 1ll * (n - 1) / 2; for(int i = 0; i < n; i ++) ans -= abs(pref[n / 2] - pref[i]); cout << ans << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 404 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 404 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 288 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 0 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 384 KB | Output is correct |
23 | Correct | 0 ms | 384 KB | Output is correct |
24 | Correct | 0 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 0 ms | 384 KB | Output is correct |
31 | Correct | 0 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 384 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 404 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 288 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 0 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 384 KB | Output is correct |
23 | Correct | 0 ms | 384 KB | Output is correct |
24 | Correct | 0 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 0 ms | 384 KB | Output is correct |
31 | Correct | 0 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 384 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
34 | Correct | 1 ms | 384 KB | Output is correct |
35 | Correct | 1 ms | 416 KB | Output is correct |
36 | Correct | 1 ms | 416 KB | Output is correct |
37 | Correct | 1 ms | 384 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 1 ms | 384 KB | Output is correct |
40 | Correct | 1 ms | 384 KB | Output is correct |
41 | Correct | 1 ms | 384 KB | Output is correct |
42 | Correct | 1 ms | 384 KB | Output is correct |
43 | Correct | 1 ms | 384 KB | Output is correct |
44 | Correct | 0 ms | 384 KB | Output is correct |
45 | Correct | 1 ms | 384 KB | Output is correct |
46 | Correct | 0 ms | 384 KB | Output is correct |
47 | Correct | 1 ms | 384 KB | Output is correct |
48 | Correct | 1 ms | 512 KB | Output is correct |
49 | Correct | 1 ms | 384 KB | Output is correct |
50 | Correct | 1 ms | 384 KB | Output is correct |
51 | Correct | 0 ms | 384 KB | Output is correct |
52 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 404 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 288 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 0 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 384 KB | Output is correct |
23 | Correct | 0 ms | 384 KB | Output is correct |
24 | Correct | 0 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 0 ms | 384 KB | Output is correct |
31 | Correct | 0 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 384 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
34 | Correct | 1 ms | 384 KB | Output is correct |
35 | Correct | 1 ms | 416 KB | Output is correct |
36 | Correct | 1 ms | 416 KB | Output is correct |
37 | Correct | 1 ms | 384 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 1 ms | 384 KB | Output is correct |
40 | Correct | 1 ms | 384 KB | Output is correct |
41 | Correct | 1 ms | 384 KB | Output is correct |
42 | Correct | 1 ms | 384 KB | Output is correct |
43 | Correct | 1 ms | 384 KB | Output is correct |
44 | Correct | 0 ms | 384 KB | Output is correct |
45 | Correct | 1 ms | 384 KB | Output is correct |
46 | Correct | 0 ms | 384 KB | Output is correct |
47 | Correct | 1 ms | 384 KB | Output is correct |
48 | Correct | 1 ms | 512 KB | Output is correct |
49 | Correct | 1 ms | 384 KB | Output is correct |
50 | Correct | 1 ms | 384 KB | Output is correct |
51 | Correct | 0 ms | 384 KB | Output is correct |
52 | Correct | 1 ms | 384 KB | Output is correct |
53 | Correct | 13 ms | 3604 KB | Output is correct |
54 | Correct | 9 ms | 3604 KB | Output is correct |
55 | Correct | 9 ms | 3476 KB | Output is correct |
56 | Correct | 9 ms | 3476 KB | Output is correct |
57 | Correct | 7 ms | 3476 KB | Output is correct |
58 | Correct | 18 ms | 3604 KB | Output is correct |
59 | Correct | 10 ms | 3476 KB | Output is correct |
60 | Correct | 10 ms | 3604 KB | Output is correct |
61 | Correct | 9 ms | 3476 KB | Output is correct |
62 | Correct | 10 ms | 3476 KB | Output is correct |
63 | Correct | 9 ms | 3476 KB | Output is correct |
64 | Correct | 16 ms | 3476 KB | Output is correct |
65 | Correct | 8 ms | 3348 KB | Output is correct |
66 | Correct | 7 ms | 3476 KB | Output is correct |
67 | Correct | 7 ms | 3476 KB | Output is correct |
68 | Correct | 7 ms | 3348 KB | Output is correct |
69 | Correct | 16 ms | 3604 KB | Output is correct |
70 | Correct | 12 ms | 3348 KB | Output is correct |
71 | Correct | 6 ms | 3604 KB | Output is correct |
72 | Correct | 6 ms | 3604 KB | Output is correct |
73 | Correct | 7 ms | 3604 KB | Output is correct |