#include "monster.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace {
int n;
} // namespace
std::vector<int> Solve(int N) {
n=N;
vector<int> v;
rep(x,0,n) v.pub(x);
stable_sort(all(v),[](int i,int j){
return !Query(i,j);
});
//for (auto &it:v) cout<<it<<" "; cout<<endl;
vector<int> vv;
rep(x,1,n) if (Query(v[0],v[x])) vv.pub(v[x]);
int l=0,r;
if (sz(vv)!=1) r=sz(vv);
else{
//if its 1: we found 2
//if its 0: we found 1
int curr=0;
//cout<<vv[0]<<endl;
rep(x,0,n) if (x!=vv[0]) curr+=Query(vv[0],x);
if (curr==2) r=1;
else r=0;
}
vector<int> rank,ans(n,0);
while (true){
rep(x,r+1,l) rank.pub(v[x]);
if (r==n-1) break;
rep(x,r+1,n) if (Query(v[l],v[x])){
l=r+1,r=x;
break;
}
}
rep(x,0,n) ans[rank[x]]=x;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
3 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
3 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
2 ms |
200 KB |
Output is correct |
16 |
Correct |
16 ms |
200 KB |
Output is correct |
17 |
Correct |
29 ms |
200 KB |
Output is correct |
18 |
Correct |
13 ms |
200 KB |
Output is correct |
19 |
Correct |
10 ms |
200 KB |
Output is correct |
20 |
Correct |
14 ms |
200 KB |
Output is correct |
21 |
Correct |
1 ms |
200 KB |
Output is correct |
22 |
Correct |
1 ms |
200 KB |
Output is correct |
23 |
Correct |
1 ms |
200 KB |
Output is correct |
24 |
Correct |
1 ms |
200 KB |
Output is correct |
25 |
Correct |
1 ms |
200 KB |
Output is correct |
26 |
Correct |
18 ms |
256 KB |
Output is correct |
27 |
Correct |
1 ms |
200 KB |
Output is correct |
28 |
Correct |
1 ms |
200 KB |
Output is correct |
29 |
Correct |
1 ms |
200 KB |
Output is correct |
30 |
Correct |
2 ms |
200 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
13 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
3 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
3 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
2 ms |
200 KB |
Output is correct |
16 |
Correct |
16 ms |
200 KB |
Output is correct |
17 |
Correct |
29 ms |
200 KB |
Output is correct |
18 |
Correct |
13 ms |
200 KB |
Output is correct |
19 |
Correct |
10 ms |
200 KB |
Output is correct |
20 |
Correct |
14 ms |
200 KB |
Output is correct |
21 |
Correct |
1 ms |
200 KB |
Output is correct |
22 |
Correct |
1 ms |
200 KB |
Output is correct |
23 |
Correct |
1 ms |
200 KB |
Output is correct |
24 |
Correct |
1 ms |
200 KB |
Output is correct |
25 |
Correct |
1 ms |
200 KB |
Output is correct |
26 |
Correct |
18 ms |
256 KB |
Output is correct |
27 |
Correct |
1 ms |
200 KB |
Output is correct |
28 |
Correct |
1 ms |
200 KB |
Output is correct |
29 |
Correct |
1 ms |
200 KB |
Output is correct |
30 |
Correct |
2 ms |
200 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
13 ms |
200 KB |
Output is correct |
33 |
Correct |
110 ms |
288 KB |
Output is correct |
34 |
Correct |
132 ms |
288 KB |
Output is correct |
35 |
Correct |
147 ms |
288 KB |
Output is correct |
36 |
Correct |
131 ms |
292 KB |
Output is correct |
37 |
Correct |
137 ms |
200 KB |
Output is correct |
38 |
Correct |
140 ms |
200 KB |
Output is correct |
39 |
Correct |
171 ms |
284 KB |
Output is correct |
40 |
Correct |
143 ms |
200 KB |
Output is correct |
41 |
Correct |
122 ms |
292 KB |
Output is correct |
42 |
Correct |
111 ms |
200 KB |
Output is correct |
43 |
Correct |
94 ms |
200 KB |
Output is correct |
44 |
Correct |
96 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
136 ms |
288 KB |
Partially correct |
2 |
Partially correct |
152 ms |
200 KB |
Partially correct |
3 |
Partially correct |
107 ms |
288 KB |
Partially correct |
4 |
Partially correct |
174 ms |
284 KB |
Partially correct |
5 |
Partially correct |
130 ms |
292 KB |
Partially correct |
6 |
Correct |
98 ms |
288 KB |
Output is correct |
7 |
Correct |
80 ms |
288 KB |
Output is correct |
8 |
Partially correct |
150 ms |
200 KB |
Partially correct |
9 |
Partially correct |
231 ms |
288 KB |
Partially correct |
10 |
Partially correct |
134 ms |
284 KB |
Partially correct |
11 |
Partially correct |
199 ms |
284 KB |
Partially correct |
12 |
Partially correct |
127 ms |
288 KB |
Partially correct |
13 |
Partially correct |
114 ms |
288 KB |
Partially correct |
14 |
Partially correct |
125 ms |
288 KB |
Partially correct |
15 |
Correct |
89 ms |
284 KB |
Output is correct |
16 |
Correct |
84 ms |
284 KB |
Output is correct |
17 |
Partially correct |
134 ms |
292 KB |
Partially correct |
18 |
Correct |
66 ms |
288 KB |
Output is correct |