# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
499121 |
2021-12-27T08:59:19 Z |
blue |
RMQ (NOI17_rmq) |
C++17 |
|
88 ms |
18292 KB |
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
const int lg = 16;
const int mx = 100'000;
using vi = vector<int>;
int st[mx][1+lg];
vi maxpow(1+mx);
int rangemin(int l, int r)
{
return min(st[l][maxpow[r-l+1]], st[r - (1 << maxpow[r-l+1]) + 1][maxpow[r-l+1]]);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
maxpow[1] = 0;
for(int i = 2; i <= mx; i++)
{
maxpow[i] = maxpow[i-1];
if((1 << (maxpow[i]+1)) == i)
maxpow[i]++;
}
int N, Q;
cin >> N >> Q;
vi le[N], re[N];
int L[Q], R[Q], A[Q];
for(int j = 0; j < Q; j++)
{
cin >> L[j] >> R[j] >> A[j];
le[L[j]].push_back(j);
re[R[j]].push_back(j);
}
multiset<int> V{0};
vi P(N);
for(int i = 0; i < N; i++)
{
for(int j: le[i])
V.insert(A[j]);
P[i] = *V.rbegin();
// cerr << i << " : ";
// for(int v: V) cerr << v << ' ';
// cerr << '\n';
//
// cerr << "P[i] = " << P[i] << '\n';
for(int j: re[i])
V.erase(V.find(A[j]));
}
for(int i = 0; i < N; i++)
st[i][0] = P[i];
for(int e = 1; e <= lg; e++)
for(int i = 0; i+(1<<e)-1 < N; i++)
st[i][e] = min(st[i][e-1], st[i + (1 << (e-1))][e-1]);
for(int j = 0; j < Q; j++)
{
if(rangemin(L[j], R[j]) != A[j])
{
for(int i = 0; i < N; i++) cout << "-1 ";
cout << '\n';
return 0;
}
}
for(int i = 0; i < N; i++) cout << P[i] << ' ';
cout << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
2 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
4 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
5 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
6 |
Correct |
1 ms |
720 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
1 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
720 KB |
Output is correct |
11 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
2 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
4 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
5 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
6 |
Correct |
1 ms |
720 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
1 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
720 KB |
Output is correct |
11 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
12 |
Partially correct |
2 ms |
848 KB |
Output is partially correct |
13 |
Partially correct |
2 ms |
860 KB |
Output is partially correct |
14 |
Partially correct |
2 ms |
720 KB |
Output is partially correct |
15 |
Partially correct |
2 ms |
848 KB |
Output is partially correct |
16 |
Partially correct |
2 ms |
860 KB |
Output is partially correct |
17 |
Partially correct |
1 ms |
848 KB |
Output is partially correct |
18 |
Partially correct |
1 ms |
848 KB |
Output is partially correct |
19 |
Partially correct |
2 ms |
724 KB |
Output is partially correct |
20 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
21 |
Correct |
2 ms |
720 KB |
Output is correct |
22 |
Correct |
2 ms |
848 KB |
Output is correct |
23 |
Correct |
1 ms |
732 KB |
Output is correct |
24 |
Correct |
2 ms |
848 KB |
Output is correct |
25 |
Correct |
1 ms |
720 KB |
Output is correct |
26 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
2 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
4 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
5 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
6 |
Correct |
1 ms |
720 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
1 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
720 KB |
Output is correct |
11 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
12 |
Partially correct |
2 ms |
848 KB |
Output is partially correct |
13 |
Partially correct |
2 ms |
860 KB |
Output is partially correct |
14 |
Partially correct |
2 ms |
720 KB |
Output is partially correct |
15 |
Partially correct |
2 ms |
848 KB |
Output is partially correct |
16 |
Partially correct |
2 ms |
860 KB |
Output is partially correct |
17 |
Partially correct |
1 ms |
848 KB |
Output is partially correct |
18 |
Partially correct |
1 ms |
848 KB |
Output is partially correct |
19 |
Partially correct |
2 ms |
724 KB |
Output is partially correct |
20 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
21 |
Correct |
2 ms |
720 KB |
Output is correct |
22 |
Correct |
2 ms |
848 KB |
Output is correct |
23 |
Correct |
1 ms |
732 KB |
Output is correct |
24 |
Correct |
2 ms |
848 KB |
Output is correct |
25 |
Correct |
1 ms |
720 KB |
Output is correct |
26 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |
27 |
Partially correct |
79 ms |
16704 KB |
Output is partially correct |
28 |
Partially correct |
78 ms |
17184 KB |
Output is partially correct |
29 |
Partially correct |
53 ms |
15580 KB |
Output is partially correct |
30 |
Partially correct |
88 ms |
18200 KB |
Output is partially correct |
31 |
Partially correct |
86 ms |
14368 KB |
Output is partially correct |
32 |
Partially correct |
67 ms |
16364 KB |
Output is partially correct |
33 |
Partially correct |
13 ms |
10348 KB |
Output is partially correct |
34 |
Partially correct |
10 ms |
7376 KB |
Output is partially correct |
35 |
Partially correct |
20 ms |
12752 KB |
Output is partially correct |
36 |
Correct |
60 ms |
16856 KB |
Output is correct |
37 |
Correct |
81 ms |
18292 KB |
Output is correct |
38 |
Correct |
8 ms |
8656 KB |
Output is correct |
39 |
Correct |
60 ms |
16828 KB |
Output is correct |
40 |
Correct |
1 ms |
720 KB |
Output is correct |
41 |
Partially correct |
1 ms |
720 KB |
Output is partially correct |