Task: | burek |
Sender: | eXeP |
Submission time: | 2016-08-02 16:09:04 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.06 s | details |
#3 | ACCEPTED | 0.06 s | details |
#4 | ACCEPTED | 0.14 s | details |
#5 | ACCEPTED | 0.20 s | details |
#6 | ACCEPTED | 0.20 s | details |
#7 | ACCEPTED | 0.28 s | details |
#8 | ACCEPTED | 0.28 s | details |
Code
#include <bits/stdc++.h> #define i64 long long #define u64 unsigned long long #define i32 int #define u32 unsigned int #define pii pair<int, int> #define pll pair<long long, long long> #define ld long double #define defmod 1000000007 #define mati64(a,b) vector<vector<i64>>(a, vector<i64>(b, 0)); using namespace std; const int p = 1<<20; int ad[2<<20], ad2[2<<20]; void add(int i, int a, int b, int l, int r, int v){ if(a >= r || b <= l) return; else if(a >= l && b <= r){ ad[i]+=v; return; } int m = (a+b)/2; add(i*2, a, m, l, r, v); add(i*2+1, m, b, l, r, v); } void add2(int i, int a, int b, int l, int r, int v){ if(a >= r || b <= l) return; else if(a >= l && b <= r){ ad2[i]+=v; return; } int m = (a+b)/2; add2(i*2, a, m, l, r, v); add2(i*2+1, m, b, l, r, v); } int g1(int i){ i+=p; int ans = 0; while(i){ ans+=ad[i]; i/=2; } return ans; } int g2(int i){ i+=p; int ans = 0; while(i){ ans+=ad2[i]; i/=2; } return ans; } int main(){ cin.sync_with_stdio(0); cin.tie(0); int n; cin >> n; int x[3][101010], y[3][101010]; for(int i = 0; i < n; ++i){ cin >> x[0][i] >> y[0][i] >> x[1][i] >> y[1][i] >> x[2][i] >> y[2][i]; int mix = min(x[0][i], min(x[1][i], x[2][i])), mx = max(x[0][i], max(x[1][i], x[2][i])); int miy = min(y[0][i], min(y[1][i], y[2][i])), my = max(y[0][i], max(y[1][i], y[2][i])); add(1, 0, p, mix+1, mx, 1); add2(1, 0, p, miy+1, my, 1); } int m; cin >> m; while(m--){ char lol; cin >> lol; if(lol == 'x'){ int c; cin >> lol >> c; cout << g1(c) << endl; } else{ int c; cin >> lol >> c; cout << g2(c) << endl; } } return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
3
1 0 0 2 2 2 1 3 3 5 4 0 5 4 4 5 4 4 4 ... |
correct output |
---|
0
1 1 2 |
user output |
---|
0 1 1 2 |
Test 2
Verdict: ACCEPTED
input |
---|
4
2 7 6 0 0 5 7 1 7 10 11 11 5 10 2 9 6 8 1 9 10 10 4 1 ... |
correct output |
---|
3
2 3 2 |
user output |
---|
3 2 3 2 |
Test 3
Verdict: ACCEPTED
input |
---|
10
84 4 53 58 73 85 60 24 59 23 1 11 80 69 61 57 83 91 84 91 3 97 1 94 ... |
correct output |
---|
0
4 1 1 5 ... |
user output |
---|
0 4 1 1 5 ... |
Test 4
Verdict: ACCEPTED
input |
---|
70000
523716 152076 196820 312652 75... |
correct output |
---|
3714
48672 41227 51089 19907 ... |
user output |
---|
3714 48672 41227 51089 19907 ... |
Test 5
Verdict: ACCEPTED
input |
---|
100000
554 492 443 655 24 170 867 578 502 743 73 276 738 487 297 633 494 469 753 268 131 447 924 530 ... |
correct output |
---|
73985
28536 71335 58180 74422 ... |
user output |
---|
73985 28536 71335 58180 74422 ... |
Test 6
Verdict: ACCEPTED
input |
---|
99999
556 490 167 620 238 60 214 608 982 363 975 378 557 111 872 233 227 61 58 477 37 808 578 225 ... |
correct output |
---|
57947
50886 46878 70092 16298 ... |
user output |
---|
57947 50886 46878 70092 16298 ... |
Test 7
Verdict: ACCEPTED
input |
---|
99999
521698 336192 884832 495601 73... |
correct output |
---|
2710
18050 45557 42424 4570 ... |
user output |
---|
2710 18050 45557 42424 4570 ... |
Test 8
Verdict: ACCEPTED
input |
---|
100000
702229 435001 483066 464189 74... |
correct output |
---|
66201
69812 28734 33874 14815 ... |
user output |
---|
66201 69812 28734 33874 14815 ... |