Submission #558134

#TimeUsernameProblemLanguageResultExecution timeMemory
558134OlympiaGame (IOI14_game)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> //#include <game.h> using namespace std; struct dsu { vector<int> parent; vector<int> compSize; int n; int cc; void fill(){ cc = n; parent.resize(n), compSize.resize(n); for(int i = 0; i < n; i++){ parent[i] = i, compSize[i] = 1; } } int find_head(int x){ if(x == parent[x]){ return x; } return find_head(parent[x]); } void join(int x, int y){ x = find_head(x); y = find_head(y); if(x == y){ return; } cc--; if(compSize[x] > compSize[y]){ swap(x,y); } parent[x] = y; compSize[y] += compSize[x]; } bool comp(int x, int y){ return (find_head(x) == find_head(y)); } }; set<pair<int,int> > edges; set<pair<int,int> > e; dsu d; void initialize (int n) { d.n = n; d.fill(); while (d.cc != 1) { int u = rand() % n; int v = rand() % n; if (!d.comp(u, v)) { edges.insert(make_pair(u, v)); d.join(u, v); } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j) { e.insert(make_pair(i, j)); } } } } int hasEdge (int u, int v) { if (!edges.count(make_pair(u, v)) && !edges.count(make_pair(v, u))) { e.erase(make_pair(u, v)); e.erase(make_pair(v, u)); return false; } d.fill(); for (auto& p: edges) { if (p != make_pair(u, v) && p != make_pair(v, u)) { d.join(p.first, p.second); } } for (auto& p: e) { if (!d.comp(p.first, p.second)) { edges.erase(make_pair(u, v)); e.erase(make_pair(u, v)); e.erase(make_pair(v, u)); edges.insert(p); return false; } } return true; } int main() { initialize(4); cout << hasEdge(0, 1) << '\n'; cout << hasEdge(1, 3) << '\n'; cout << hasEdge(1, 2) << '\n'; cout << hasEdge(2, 0) << '\n'; cout << hasEdge(2, 3) << '\n'; cout << hasEdge(0, 3) << '\n'; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccI2g8Td.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccDpxOBb.o:game.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status