Submission #603530

#TimeUsernameProblemLanguageResultExecution timeMemory
603530Sam_a17Comparing Plants (IOI20_plants)C++14
Compilation error
0 ms0 KiB
// #include "A.cpp" #include <bits/stdc++.h> // #include <vector> using namespace std; #define sz(x) (int((x).size())) #define len(x) (int)x.length() #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define dbg(x) cout << #x << " " << x << endl; #define uniq(x) x.resize(unique(all(x)) - x.begin()); #define pb push_back #define ld long double #define ll long long void build(std::vector<std::vector<int>> p); const int N = 2e5 + 10, M = 5; int par[N], sz[N]; set<int> st[N]; bitset<M> biti[M]; int find(int a) { if(a != par[a]) { par[a] = find(par[a]); } return par[a]; } int same(int a, int b) { if(find(a) == find(b)) { return 1; } else { return 0; } } int merge(int a, int b) { a = find(a), b = find(b); if(a == b) { return 0; } if(sz[a] < sz[b]) { swap(a, b); } par[b] = a, sz[a] += sz[b]; for(auto i: st[b]) { st[a].insert(i); } st[b].clear(); return 1; } int construct(std::vector<std::vector<int>> p) { int n = p.size(); bool allOne = true, lowerOne = true, zeroOrtwo = true; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j] != 1) { allOne = false; } if(p[i][j] > 1) { lowerOne = false; } if(i == j) continue; if(p[i][j] == 1 || p[i][j] == 3) { zeroOrtwo = false; } } } for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j] != p[j][i]) { return 0; } } } if(allOne) { vector<vector<int>> answ(n, vector<int> (n, 0)); for(int i = 0; i < n - 1; i++){ answ[i][i + 1] = 1; answ[i + 1][i] = 1; } build(answ); return 1; } if(lowerOne) { vector<vector<int>> answ(n, vector<int> (n, 0)); for(int i = 0; i < n; i++) { par[i] = i, sz[i] = 1; } for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j] == 1) { if(merge(i, j)) { answ[i][j] = answ[j][i] = 1; } } } } for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(same(i, j) != p[i][j]) { return 0; } } } build(answ); return 1; } if(zeroOrtwo){ vector<vector<int>> answ(n, vector<int> (n, 0)); for(int i = 0; i < n; i++) { par[i] = i, sz[i] = 1; st[i].insert(i); } for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j]) biti[i][j] = 1; } } // vector<int> out(n, 0); vector<int> ans, vis(n); vector<vector<int>> components; for(int i = 0; i < n; i++) { if(vis[i]) continue; // dbg(i) for(int j = 0; j < n; j++) { if(p[i][j] == 2) { // dbg(j) merge(i, j); } } int pa = find(i); const int x = n; bitset<M> bt; for(auto j: st[pa]) { bt[j] = 1; } // cout << bt << endl; for(auto j: st[pa]) { if((biti[j] | bt) != bt || (biti[j] & bt) != bt) { return 0; } } if(sz(st[pa]) == 2) { return 0; } vector<int> comp; for(auto j: st[pa]) { vis[j] = true; comp.push_back(j); } components.push_back(comp); } for(auto i: components) { for(int j = 1; j < sz(i); j++) { answ[i[j]][i[j - 1]] = 1; answ[i[j - 1]][i[j]] = 1; } answ[i.back()][i.front()] = 1; answ[i.front()][i.back()] = 1; } build(answ); return 1; } return 1; }

Compilation message (stderr)

plants.cpp: In function 'int construct(std::vector<std::vector<int> >)':
plants.cpp:153:17: warning: unused variable 'x' [-Wunused-variable]
  153 |       const int x = n;
      |                 ^
/usr/bin/ld: /tmp/ccfKXsUS.o: in function `construct(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)':
plants.cpp:(.text+0xa25): undefined reference to `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
/usr/bin/ld: plants.cpp:(.text+0x1330): undefined reference to `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
/usr/bin/ld: plants.cpp:(.text+0x13e1): undefined reference to `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
/usr/bin/ld: /tmp/ccRN73zT.o: in function `main':
grader.cpp:(.text.startup+0x2fb): undefined reference to `init(int, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x347): undefined reference to `compare_plants(int, int)'
collect2: error: ld returned 1 exit status