Submission #305786

#TimeUsernameProblemLanguageResultExecution timeMemory
305786tincanConnecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include<iostream> #include<algorithm> #include<cstring> #include<queue> #include<vector> #include<cmath> #include<map> #include<stack> #include<set> #include<deque> #include<string> #include<unordered_map> #include<bitset> #include<random> #include<chrono> //Eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee using namespace std; const int MAXN = 1005; struct dsu { int arr[MAXN]; int find(int s) { return arr[s] == s ? s : arr[s] = find(arr[s]); } void join(int a, int b) { if (find(a) != find(b)) arr[find(a)] = find(b); } } st, st2; vector<int> thng[MAXN]; void make(int i, int i2, vector<vector<int>> &ans) { ans[i][i2] = ans[i2][i] = 1; } int construct(vector<vector<int>> p) { int N = p.size(); for (int i = 0; i < N; i++) for (int i2 = 0; i2 < N; i2++) if (p[i][i2] == 3) return 0; vector<vector<int>> ans; for (int i = 0; i < N; i++) { ans.push_back(vector<int>(N)); for (int i2 = 0; i2 < N; i2++) ans[i][i2] = 0; } for (int i = 0; i < N; i++) { for (int i2 = i+1; i2 < N; i2++) { if (p[i][i2]) { if(p[i][i2] == 1) st2.join(i, i2); st.join(i, i2); } else if (!p[i][i2] && st.find(i) == st.find(i2)) return 0; } } for (int i = 0; i < N; i++) { if (thng[st2.find(i)].size()) make(thng[st2.find(i)].back, i, ans); thng[st2.find(i)].push_back(i); } for (int i = 0; i < N; i++) { for (int i2 =i+1; i2 < N; i2++) { if (p[i][i2] == 2) make(st2.find(i), st2.find(i2), ans); } } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:46:68: error: cannot resolve overloaded function 'back' based on conversion to type 'int'
   46 |   if (thng[st2.find(i)].size()) make(thng[st2.find(i)].back, i, ans);
      |                                                                    ^
supertrees.cpp:54:2: error: 'build' was not declared in this scope
   54 |  build(ans); return 1;
      |  ^~~~~