Task: | Archaeological Research |
Sender: | zxc |
Submission time: | 2016-08-04 17:00:07 +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.05 s | details |
#4 | ACCEPTED | 0.06 s | details |
#5 | ACCEPTED | 0.06 s | details |
#6 | ACCEPTED | 0.06 s | details |
#7 | ACCEPTED | 0.05 s | details |
#8 | ACCEPTED | 0.06 s | details |
#9 | ACCEPTED | 0.06 s | details |
#10 | ACCEPTED | 0.15 s | details |
#11 | ACCEPTED | 0.14 s | details |
#12 | ACCEPTED | 0.06 s | details |
#13 | ACCEPTED | 0.06 s | details |
#14 | ACCEPTED | 0.07 s | details |
#15 | ACCEPTED | 0.20 s | details |
#16 | ACCEPTED | 0.57 s | details |
#17 | ACCEPTED | 0.20 s | details |
#18 | ACCEPTED | 0.59 s | details |
#19 | ACCEPTED | 0.06 s | details |
#20 | ACCEPTED | 0.05 s | details |
#21 | ACCEPTED | 0.06 s | details |
#22 | ACCEPTED | 0.06 s | details |
#23 | ACCEPTED | 0.08 s | details |
#24 | ACCEPTED | 0.11 s | details |
#25 | ACCEPTED | 0.21 s | details |
#26 | ACCEPTED | 0.42 s | details |
#27 | ACCEPTED | 0.21 s | details |
#28 | ACCEPTED | 0.21 s | details |
#29 | ACCEPTED | 0.21 s | details |
#30 | ACCEPTED | 0.21 s | details |
#31 | ACCEPTED | 0.46 s | details |
#32 | ACCEPTED | 0.45 s | details |
#33 | ACCEPTED | 0.47 s | details |
#34 | ACCEPTED | 0.49 s | details |
Code
#include <iostream> #include <cstring> #include <vector> using namespace std; const int MN = 5e5+100; /* struct Node { int ma = 0; Node * left; Node * right; Node(int v) { sum = v; } } Node * t[MN]; int ma(Node * a) { if(a == NULL) return 0; return a->ma; } int setValue(Node*& k, int l, int r, int x) { if(l > x || r < x) { return ma(k); } if(l == r) { Node * n2 = new Node(1); k = n2; return ma(k); } if(k == NULL) { k = new Node(0); } int mid = (l+r)/2; int q = setValue(k->left, l, mid, x); int w = setValue(k->right, mid+1, r, x); k->ma = max(q, w); } int lol = 0; int find(Node* kb, Node *ke, int l, int r) { if(k2 == NULL) { return 0; } if(sum(k) == (r-l+1)) { lol = max(lol, r+1); return 1; } if(k == NULL) { return 0; } int mid = (l+r)/2; if(find(k->left, l, mid)) { find(k->right, mid+1, r); } return 0; } */ const int N = 1<<19; int st[2*N]; vector<int> t[MN]; int getMin(int a, int b) { a += N; b += N; int mi = 1e9; for(; a <= b; a/=2, b/=2) { if(a&1) mi = min(mi, st[a++]); if(~b&1) mi = min(mi, st[b--]); } return mi; } void setValue(int a, int v) { a += N; st[a] = v; for(a/=2; a; a/=2) { st[a] = min(st[a*2], st[a*2+1]); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; cout<<1<<' '; for(int i = 0; i < n; ++i) { int c; cin>>c; for(int j = 0; j < c; ++j) { int x; cin>>x; --x; t[x].push_back(i); } } memset(st, -1, sizeof st); setValue(0, 1e9); for(int i = 1; i < n; ++i) { if(t[i].size() == 0) { setValue(1, i); cout<<1<<' '; } else { int ma = 1; for(int x: t[i]) { int b = x+1; int lo = 0; int hi = n; int best = 0; while(lo <= hi) { int mid = (lo+hi)/2; if(getMin(0, mid) >= b) { best = mid; lo = mid+1; } else { hi = mid-1; } } ma = max(ma, best+1); } cout<<ma<<' '; setValue(ma, i); } } cout<<endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
4 3 2 3 4 2 4 3 1 4 0 |
correct output |
---|
1 1 2 3 |
user output |
---|
1 1 2 3 |
Test 2
Verdict: ACCEPTED
input |
---|
5 1 2 1 4 1 4 1 5 ... |
correct output |
---|
1 1 1 2 1 |
user output |
---|
1 1 1 2 1 |
Test 3
Verdict: ACCEPTED
input |
---|
1 0 |
correct output |
---|
1 |
user output |
---|
1 |
Test 4
Verdict: ACCEPTED
input |
---|
4 0 0 0 0 |
correct output |
---|
1 1 1 1 |
user output |
---|
1 1 1 1 |
Test 5
Verdict: ACCEPTED
input |
---|
10 1 10 1 9 1 8 1 7 ... |
correct output |
---|
1 1 1 1 1 1 2 3 4 5 |
user output |
---|
1 1 1 1 1 1 2 3 4 5 |
Test 6
Verdict: ACCEPTED
input |
---|
10 9 10 9 8 7 6 5 4 3 2 0 0 0 ... |
correct output |
---|
1 1 2 3 4 5 6 7 8 9 |
user output |
---|
1 1 2 3 4 5 6 7 8 9 |
Test 7
Verdict: ACCEPTED
input |
---|
20 14 2 3 4 5 6 7 8 9 10 12 14 16... |
correct output |
---|
1 1 2 3 4 5 6 7 8 9 1 10 1 11 ... |
user output |
---|
1 1 2 3 4 5 6 7 8 9 1 10 1 11 ... |
Test 8
Verdict: ACCEPTED
input |
---|
10 3 6 4 7 3 3 6 7 3 7 5 4 0 ... |
correct output |
---|
1 1 1 2 1 3 4 1 2 1 |
user output |
---|
1 1 1 2 1 3 4 1 2 1 |
Test 9
Verdict: ACCEPTED
input |
---|
100 4 8 29 3 14 4 29 17 5 11 8 8 14 17 19 10 29 5 11 4 7 11 19 14 ... |
correct output |
---|
1 1 2 1 3 1 2 4 1 5 6 1 2 7 3 ... |
user output |
---|
1 1 2 1 3 1 2 4 1 5 6 1 2 7 3 ... |
Test 10
Verdict: ACCEPTED
input |
---|
100000 1 5 0 0 1 21 ... |
correct output |
---|
1 1 1 1 2 1 1 1 1 1 2 1 1 3 1 ... |
user output |
---|
1 1 1 1 2 1 1 1 1 1 2 1 1 3 1 ... |
Test 11
Verdict: ACCEPTED
input |
---|
300000 0 0 0 0 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 12
Verdict: ACCEPTED
input |
---|
10 5 2 4 6 8 10 2 3 5 2 7 9 0 ... |
correct output |
---|
1 1 1 2 3 4 1 5 6 7 |
user output |
---|
1 1 1 2 3 4 1 5 6 7 |
Test 13
Verdict: ACCEPTED
input |
---|
1000 504 2 4 6 8 10 12 14 16 18 20 ... |
correct output |
---|
1 1 1 2 3 4 5 6 1 7 8 9 10 11 ... |
user output |
---|
1 1 1 2 3 4 5 6 1 7 8 9 10 11 ... |
Test 14
Verdict: ACCEPTED
input |
---|
10000 5006 2 4 6 8 10 12 14 16 18 20... |
correct output |
---|
1 1 2 3 1 4 5 6 1 7 1 8 2 9 1 ... |
user output |
---|
1 1 2 3 1 4 5 6 1 7 1 8 2 9 1 ... |
Test 15
Verdict: ACCEPTED
input |
---|
100000 50001 2 4 6 8 10 12 14 16 18 2... |
correct output |
---|
1 1 1 2 1 3 1 4 2 5 6 7 8 9 1 ... |
user output |
---|
1 1 1 2 1 3 1 4 2 5 6 7 8 9 1 ... |
Test 16
Verdict: ACCEPTED
input |
---|
300000 150003 2 4 6 8 10 12 14 16 18 ... |
correct output |
---|
1 1 2 3 1 4 1 5 1 6 2 7 1 8 9 ... |
user output |
---|
1 1 2 3 1 4 1 5 1 6 2 7 1 8 9 ... |
Test 17
Verdict: ACCEPTED
input |
---|
100000 99999 2 3 4 5 6 7 8 9 10 11 12... |
correct output |
---|
1 1 2 3 4 5 6 7 8 9 10 11 12 1... |
user output |
---|
1 1 2 3 4 5 6 7 8 9 10 11 12 1... |
Test 18
Verdict: ACCEPTED
input |
---|
300000 299999 2 3 4 5 6 7 8 9 10 11 1... |
correct output |
---|
1 1 2 3 4 5 6 7 8 9 10 11 12 1... |
user output |
---|
1 1 2 3 4 5 6 7 8 9 10 11 12 1... |
Test 19
Verdict: ACCEPTED
input |
---|
10 6 3 10 5 7 2 6 4 9 7 3 5 4 9 4 6 8 2 9 6 ... |
correct output |
---|
1 1 2 1 3 4 5 2 6 7 |
user output |
---|
1 1 2 1 3 4 5 2 6 7 |
Test 20
Verdict: ACCEPTED
input |
---|
100 2 5 76 0 1 95 0 ... |
correct output |
---|
1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 ... |
user output |
---|
1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 ... |
Test 21
Verdict: ACCEPTED
input |
---|
100 42 10 58 79 63 54 85 98 93 12 ... |
correct output |
---|
1 1 1 1 2 1 3 4 5 6 7 8 9 10 1... |
user output |
---|
1 1 1 1 2 1 3 4 5 6 7 8 9 10 1... |
Test 22
Verdict: ACCEPTED
input |
---|
1000 3 159 391 64 2 873 937 2 778 683 4 834 451 612 77 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 23
Verdict: ACCEPTED
input |
---|
1000 128 727 119 723 512 20 702 768... |
correct output |
---|
1 1 1 1 1 1 1 2 3 4 1 1 2 5 1 ... |
user output |
---|
1 1 1 1 1 1 1 2 3 4 1 1 2 5 1 ... |
Test 24
Verdict: ACCEPTED
input |
---|
10000 11 8022 4007 5739 6750 8840 92... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 25
Verdict: ACCEPTED
input |
---|
10000 28 5794 5411 4358 9433 717 593... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 26
Verdict: ACCEPTED
input |
---|
100000 4 48646 24905 713 44172 3 50179 91540 78627 4 20753 74464 38091 58997 3 29870 60334 51008 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 27
Verdict: ACCEPTED
input |
---|
10000 128 8450 9019 4143 8758 3101 2... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 ... |
Test 28
Verdict: ACCEPTED
input |
---|
10000 186 213 4022 6061 5193 6771 72... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 29
Verdict: ACCEPTED
input |
---|
10000 319 8261 3202 7324 8009 3747 9... |
correct output |
---|
1 1 1 1 1 1 1 2 1 1 1 1 1 3 1 ... |
user output |
---|
1 1 1 1 1 1 1 2 1 1 1 1 1 3 1 ... |
Test 30
Verdict: ACCEPTED
input |
---|
10000 589 2436 5025 2836 9734 5614 5... |
correct output |
---|
1 1 1 1 1 1 1 2 1 3 1 4 1 2 5 ... |
user output |
---|
1 1 1 1 1 1 1 2 1 3 1 4 1 2 5 ... |
Test 31
Verdict: ACCEPTED
input |
---|
100000 19 25480 79606 99089 67483 481... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 32
Verdict: ACCEPTED
input |
---|
100000 10 41727 71826 90941 24242 433... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 33
Verdict: ACCEPTED
input |
---|
100000 34 68778 88879 77791 86202 693... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 34
Verdict: ACCEPTED
input |
---|
100000 53 44024 90387 2670 24853 2560... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |