# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
131259 |
2019-07-16T21:48:07 Z |
Blagojce |
Game (IOI14_game) |
C++11 |
|
2 ms |
380 KB |
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x),end(x)
#define what_is(x) cout<<#x<<' '<<x<<endl
#include "game.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
ll const inf = 1e9;
ll const mod = 1e9 + 7;
ld const eps = 1e-9;
int link1[2000];
int SIZE1[2000];
int link2[2000];
int SIZE2[2000];
int A, B;
int findx1(int x){
while(x != link1[x]) x = link1[x];
return x;
}
bool same1(int a, int b){
return findx1(a) == findx1(b);
}
void unite1(int a, int b){
A --;
a = findx1(a);
b = findx1(b);
if(SIZE1[a] < SIZE1[b]) swap(a, b);
SIZE1[a] += SIZE1[b];
link1[a] = b;
}
int findx2(int x){
while(x != link2[x]) x = link2[x];
return x;
}
bool same2(int a, int b){
return findx2(a) == findx2(b);
}
void unite2(int a, int b){
B --;
a = findx2(a);
b = findx2(b);
if(SIZE2[a] < SIZE2[b]) swap(a, b);
SIZE2[a] += SIZE2[b];
link2[a] = b;
}
void initialize(int n) {
A = B = n;
fr(i, 0, n){
link1[i] = i;
link2[i] = i;
}
fr(i, 0, n){
SIZE2[i] = 1;
SIZE2[i] = 1;
}
}
int hasEdge(int u, int v) {
if(same1(u, v)) return 1;
else if(same2(u, v)) return 0;
else{
if(A > B){
unite1(u, v);
return 1;
}
else{
unite2(u, v);
return 0;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
280 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |