Task: | Ispiti |
Sender: | henrikaalto |
Submission time: | 2019-07-25 15:21:26 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | WRONG ANSWER | 0.04 s | details |
#4 | ACCEPTED | 0.05 s | details |
#5 | WRONG ANSWER | 0.07 s | details |
#6 | WRONG ANSWER | 0.08 s | details |
#7 | WRONG ANSWER | 0.11 s | details |
#8 | WRONG ANSWER | 0.15 s | details |
#9 | WRONG ANSWER | 0.23 s | details |
#10 | WRONG ANSWER | 0.26 s | details |
Code
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define F first #define S second using pi=pair<int,int>; const int inf = 1e9; struct segtree { vector<pi> puu; int N; segtree() { N = 1 << 19; puu.resize(N * 2, make_pair(0, 0)); } // l, r = target // ll, rr = current void muuta(int l, int r, int ll, int rr, int s, pi x) { if (rr < l || r < ll) return; //cout << "muuta: " << l << ", " << r << ", " << ll << ", " << rr << ", " << s << ", " << x.F << ", " << x.S << "\n"; if (l <= ll && rr <= r) { puu[s] = x; return; } int w = (rr - ll) / 2; muuta(l, r, ll, ll + w, s * 2, x); muuta(l, r, ll + w + 1, rr, s * 2 + 1, x); puu[s] = max(puu[s*2],puu[s*2+1]); } int hae(int l, int ll ,int rr, int s, int x, int itse) { if (rr < l) return inf; // //cout<<"hae "<<l<<" " << ll<< " "<<rr<< " " <<x <<"\n"; if (puu[s].F < x) return inf; if (s >= N) { //cout<<"löytyi: kohta: " << ll << " x: " << x << " index: " << puu[s].S << " arvo: " << puu[s].F << " itse: " << itse << "\n"; if (puu[s].S == itse) return inf; return puu[s].S; } int w = (rr - ll) / 2; int r = hae(l, ll, ll + w, s * 2, x, itse); if (r == inf) return hae(l, ll + w + 1, rr, s * 2 + 1, x, itse); return r; } void muuta(int l, pi x) { //cout << "MUUTA("<<l<<","<<"{"<<x.F<<","<<x.S<<"});\n"; muuta(l, l, 0, N - 1, 1, x); } int hae(int l, int x, int itse) { //cout<<"HAE("<<l<<","<<x<<");\n"; return hae(l, 0, N - 1, 1, x, itse); } }; int main() { int n; cin >> n; vector<pi> o; vector<pair<int, pi>>q; vector<pi> orig(n * 2); int idx = 1; for (int i = 0; i < n; ++i) { char c; cin >> c; int a, b; if (c == 'D') { cin >> a >> b; q.emplace_back(0, make_pair(a, b)); o.emplace_back(b, -a); } else { cin >> a; q.emplace_back(1, make_pair(a, a)); } } sort(all(o)); vector<int> start(o.size()); segtree lol; for (int i = 0; i < n; ++i) { if (q[i].F == 0) { int it = lower_bound(all(o), make_pair(q[i].S.S, -q[i].S.F)) - o.begin(); lol.muuta(it + 1, make_pair(q[i].S.F, idx)); orig[idx++] = q[i].S; } else { auto z = orig[q[i].S.F]; // //cout << z.F << " " << z.S << "\n"; int it = lower_bound(all(o), make_pair(z.S, -inf)) - o.begin(); int y = lol.hae(it + 1, z.F, q[i].S.F); if (y == inf) cout << "NE\n"; else cout << y << "\n"; } } } /* find first point where A >= A_i (B_i) |---------------------- --------------------------------------> B */
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
9
D 2 1000000000 D 5 1000000000 D 9 1000000000 P 2 ... |
correct output |
---|
3
NE 4 5 |
user output |
---|
3 NE 5 5 |
Test 2
Verdict: ACCEPTED
input |
---|
16
D 4 10 D 3 50 P 1 P 2 ... |
correct output |
---|
NE
NE 3 3 6 ... |
user output |
---|
NE NE 3 3 6 ... |
Test 3
Verdict: WRONG ANSWER
input |
---|
30000
D 15194 31331 D 1646 19709 P 1 D 646 12738 ... |
correct output |
---|
NE
2 NE NE 4 ... |
user output |
---|
NE 2 NE NE 4 ... Truncated |
Test 4
Verdict: ACCEPTED
input |
---|
39999
D 1999999999 1999999999 D 1999999999 1000000001 D 1999999998 1000000002 D 1999999997 1000000003 ... |
correct output |
---|
1
1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 5
Verdict: WRONG ANSWER
input |
---|
60000
D 1999999999 1999999999 D 1999999999 1000000001 D 1999999998 1000000002 D 1999999997 1000000003 ... |
correct output |
---|
1
1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 6
Verdict: WRONG ANSWER
input |
---|
70000
D 1999999999 1999999999 D 1999999999 1000000001 D 1999999998 1000000002 D 1999999997 1000000003 ... |
correct output |
---|
1
1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 7
Verdict: WRONG ANSWER
input |
---|
90000
D 1999999999 1999999999 D 1999999999 1000000001 D 1999999998 1000000002 D 1999999997 1000000003 ... |
correct output |
---|
1
1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 8
Verdict: WRONG ANSWER
input |
---|
120000
D 1999999999 1999999999 D 1999999999 1000000001 D 1999999998 1000000002 D 1999999997 1000000003 ... |
correct output |
---|
1
1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 9
Verdict: WRONG ANSWER
input |
---|
180000
D 1999999999 1999999999 D 1999999999 1000000001 D 1999999998 1000000002 D 1999999997 1000000003 ... |
correct output |
---|
1
1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 10
Verdict: WRONG ANSWER
input |
---|
200000
D 1999999999 1999999999 D 1999999999 1000000001 D 1999999998 1000000002 D 1999999997 1000000003 ... |
correct output |
---|
1
1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... Truncated |