# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
429645 | Amylopectin | Game (IOI14_game) | C++14 | 535 ms | 19076 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <stdio.h>
#include "game.h"
//#include "grader.cpp"
using namespace std;
const int mxn = 2e3 + 10;
int gr[mxn] = {},ctg[mxn][mxn] = {},ra[mxn] = {},n,mem[mxn] = {};
int figr(int l)
{
int cn = l,f;
while(gr[cn] != cn)
{
cn = gr[cn];
}
while(gr[l] != l)
{
f = gr[l];
gr[l] = cn;
l = f;
}
return cn;
}
int mer(int l,int r)
{
int pl,pr,f,i,j;
pl = figr(l);
pr = figr(r);
if(ra[pl] < ra[pr])
{
f = pl;
pl = pr;
pr = f;
}
gr[pr] = pl;
mem[pl] += mem[pr];
if(ra[pl] == ra[pr])
{
ra[pl] ++;
}
for(i=0; i<n; i++)
{
ctg[pl][i] += ctg[pr][i];
ctg[i][pl] += ctg[i][pr];
}
return 0;
}
void initialize(int nn)
{
int i,j;
n = nn;
for(i=0; i<n; i++)
{
mem[i] = 1;
gr[i] = i;
}
}
int hasEdge(int u, int v)
{
int i,j,pl = figr(u),pr = figr(v);
if(pl == pr)
{
return 0;
}
ctg[pl][pr] ++;
ctg[pr][pl] ++;
if(ctg[pl][pr] == mem[pl] * mem[pr])
{
mer(pl,pr);
return 1;
}
return 0;
}
//int main()
//{
// cout << "Hello world!" << endl;
// return 0;
//}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |