# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
641427 |
2022-09-16T17:24:11 Z |
MasterTaster |
Game (IOI14_game) |
C++14 |
|
657 ms |
78012 KB |
#include <iostream>
#include <set>
#include "game.h"
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second
using namespace std;
int dsu[1510], rnk[1510], n, cnt[1510][1510];
set<pii> svi;
int root(int u)
{
while (u!=dsu[u])
{
dsu[u]=dsu[dsu[u]];
u=dsu[u];
}
return u;
}
void connect(int ru, int rv)
{
//if (root(u)==root(v)) return;
if (rnk[ru]<=rnk[rv])
{
if (rnk[ru]==rnk[rv]) rnk[rv]++;
dsu[ru]=rv;
}
else
dsu[rv]=ru;
int r=root(ru);
int pr=ru+rv-r;
///cout<<ru<<"+"<<rv<<"->"<<r<<endl;
for (int i=0; i<n; i++) {
cnt[i][r]+=cnt[i][pr];
cnt[r][i]+=cnt[i][pr];
}
}
void initialize(int N) {
n=N;
for (int i=0; i<n; i++) for (int j=0; j<n; j++) { if (i<j) svi.insert({i, j}); cnt[i][j]=1; }
for (int i=0; i<n; i++) { dsu[i]=i; rnk[i]=1; }
}
void out()
{
for (int i=0; i<n; i++) { for (int j=0; j<n; j++) if (i!=j) cout<<cnt[i][j]<<" "; else cout<<-1<<" "; cout<<endl; }
}
int hasEdge(int u, int v) {
if (u>v) swap(u, v);
int ru, rv; ru=root(u); rv=root(v);
if (ru==rv) return 1;
if (cnt[ru][rv]>1)
{
cnt[ru][rv]--;
cnt[rv][ru]--;
return 0;
}
else
{
connect(ru, rv);
//out();
return 1;
}
/*svi.erase({u, v});
bool moze=true;
for (auto par:svi)
{
int a, b; a=par.xx; b=par.yy;
//cout<<a<<" "<<b<<" "<<root(a)<<" "<<root(b)<<" "<<ru<<" "<<rv<<endl;
if ((root(a)==ru && root(b)==rv) || (root(a)==rv && root(b)==ru)) { moze=false; break; }
}
if (!moze) return 0;
connect(u, v);
return 1;*/
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
312 KB |
Output is correct |
16 |
Correct |
0 ms |
308 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
312 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
308 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
304 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
308 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
308 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
440 KB |
Output is correct |
29 |
Correct |
1 ms |
436 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
468 KB |
Output is correct |
34 |
Correct |
2 ms |
836 KB |
Output is correct |
35 |
Correct |
2 ms |
724 KB |
Output is correct |
36 |
Correct |
2 ms |
836 KB |
Output is correct |
37 |
Correct |
2 ms |
852 KB |
Output is correct |
38 |
Correct |
2 ms |
852 KB |
Output is correct |
39 |
Correct |
2 ms |
852 KB |
Output is correct |
40 |
Correct |
3 ms |
724 KB |
Output is correct |
41 |
Correct |
2 ms |
724 KB |
Output is correct |
42 |
Correct |
2 ms |
828 KB |
Output is correct |
43 |
Correct |
2 ms |
832 KB |
Output is correct |
44 |
Correct |
2 ms |
852 KB |
Output is correct |
45 |
Correct |
2 ms |
844 KB |
Output is correct |
46 |
Correct |
2 ms |
724 KB |
Output is correct |
47 |
Correct |
3 ms |
852 KB |
Output is correct |
48 |
Correct |
2 ms |
852 KB |
Output is correct |
49 |
Correct |
2 ms |
832 KB |
Output is correct |
50 |
Correct |
2 ms |
724 KB |
Output is correct |
51 |
Correct |
2 ms |
852 KB |
Output is correct |
52 |
Correct |
2 ms |
832 KB |
Output is correct |
53 |
Correct |
2 ms |
832 KB |
Output is correct |
54 |
Correct |
2 ms |
764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
308 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
308 KB |
Output is correct |
12 |
Correct |
1 ms |
312 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
308 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
436 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
468 KB |
Output is correct |
34 |
Correct |
2 ms |
852 KB |
Output is correct |
35 |
Correct |
2 ms |
832 KB |
Output is correct |
36 |
Correct |
2 ms |
852 KB |
Output is correct |
37 |
Correct |
2 ms |
852 KB |
Output is correct |
38 |
Correct |
2 ms |
724 KB |
Output is correct |
39 |
Correct |
2 ms |
832 KB |
Output is correct |
40 |
Correct |
2 ms |
852 KB |
Output is correct |
41 |
Correct |
3 ms |
828 KB |
Output is correct |
42 |
Correct |
3 ms |
852 KB |
Output is correct |
43 |
Correct |
2 ms |
852 KB |
Output is correct |
44 |
Correct |
2 ms |
724 KB |
Output is correct |
45 |
Correct |
2 ms |
828 KB |
Output is correct |
46 |
Correct |
2 ms |
852 KB |
Output is correct |
47 |
Correct |
2 ms |
840 KB |
Output is correct |
48 |
Correct |
2 ms |
828 KB |
Output is correct |
49 |
Correct |
2 ms |
852 KB |
Output is correct |
50 |
Correct |
2 ms |
852 KB |
Output is correct |
51 |
Correct |
2 ms |
852 KB |
Output is correct |
52 |
Correct |
2 ms |
852 KB |
Output is correct |
53 |
Correct |
2 ms |
852 KB |
Output is correct |
54 |
Correct |
3 ms |
832 KB |
Output is correct |
55 |
Correct |
61 ms |
11196 KB |
Output is correct |
56 |
Correct |
59 ms |
11188 KB |
Output is correct |
57 |
Correct |
59 ms |
11204 KB |
Output is correct |
58 |
Correct |
57 ms |
11268 KB |
Output is correct |
59 |
Correct |
80 ms |
11236 KB |
Output is correct |
60 |
Correct |
57 ms |
11184 KB |
Output is correct |
61 |
Correct |
58 ms |
11260 KB |
Output is correct |
62 |
Correct |
67 ms |
11284 KB |
Output is correct |
63 |
Correct |
60 ms |
11216 KB |
Output is correct |
64 |
Correct |
56 ms |
11216 KB |
Output is correct |
65 |
Correct |
59 ms |
11172 KB |
Output is correct |
66 |
Correct |
75 ms |
11376 KB |
Output is correct |
67 |
Correct |
80 ms |
11192 KB |
Output is correct |
68 |
Correct |
58 ms |
11244 KB |
Output is correct |
69 |
Correct |
59 ms |
11208 KB |
Output is correct |
70 |
Correct |
79 ms |
11200 KB |
Output is correct |
71 |
Correct |
63 ms |
11212 KB |
Output is correct |
72 |
Correct |
59 ms |
11208 KB |
Output is correct |
73 |
Correct |
57 ms |
11284 KB |
Output is correct |
74 |
Correct |
72 ms |
11176 KB |
Output is correct |
75 |
Correct |
61 ms |
11284 KB |
Output is correct |
76 |
Correct |
138 ms |
23112 KB |
Output is correct |
77 |
Correct |
149 ms |
23092 KB |
Output is correct |
78 |
Correct |
144 ms |
23112 KB |
Output is correct |
79 |
Correct |
144 ms |
23180 KB |
Output is correct |
80 |
Correct |
145 ms |
23116 KB |
Output is correct |
81 |
Correct |
140 ms |
23088 KB |
Output is correct |
82 |
Correct |
135 ms |
23036 KB |
Output is correct |
83 |
Correct |
139 ms |
23020 KB |
Output is correct |
84 |
Correct |
138 ms |
23116 KB |
Output is correct |
85 |
Correct |
271 ms |
37940 KB |
Output is correct |
86 |
Correct |
246 ms |
38220 KB |
Output is correct |
87 |
Correct |
256 ms |
38224 KB |
Output is correct |
88 |
Correct |
264 ms |
37964 KB |
Output is correct |
89 |
Correct |
247 ms |
38056 KB |
Output is correct |
90 |
Correct |
258 ms |
38036 KB |
Output is correct |
91 |
Correct |
255 ms |
38140 KB |
Output is correct |
92 |
Correct |
249 ms |
37956 KB |
Output is correct |
93 |
Correct |
268 ms |
37940 KB |
Output is correct |
94 |
Correct |
657 ms |
77900 KB |
Output is correct |
95 |
Correct |
578 ms |
77928 KB |
Output is correct |
96 |
Correct |
568 ms |
78012 KB |
Output is correct |
97 |
Correct |
571 ms |
77940 KB |
Output is correct |
98 |
Correct |
621 ms |
77952 KB |
Output is correct |
99 |
Correct |
637 ms |
77932 KB |
Output is correct |
100 |
Correct |
640 ms |
77948 KB |
Output is correct |