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 <algorithm>
#include <set>
#include <bitset>
using namespace std;
bitset<1505> bits[1505];
int cnt[1505] = {};
set<int> block;
void initialize(int n){
for (int i = 0;i < 1505;i++) {
cnt[i] = 1;
}
}
int hasEdge(int a, int b){
if (cnt[a] == 1 || cnt[b] == 1) {
int inset = -1;
if (block.find(a) == block.end()) inset = a, block.insert(a);
if (block.find(b) == block.end()) inset = b, block.insert(b);
for (int i = 0;i < 1505;i++) {
if (i != a && i != b) {
if (!bits[inset][i]) {
cnt[i]++;
}
} else {
cnt[i] = -100000;
}
}
bits[a][b] = bits[b][a] = 1;
return 1;
} else {
bits[a][b] = bits[b][a] = 1;
if (block.find(a) != block.end()) cnt[b]--;
if (block.find(b) != block.end()) cnt[a]--;
return 0;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |