Submission #419411

#TimeUsernameProblemLanguageResultExecution timeMemory
419411vkgainzConnecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; void build(vector<vector<int>> &b); int construct(vector<vector<int>> &p) { int n = (int) p.size(); vector<int> mx(n); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j] == 3) return 0; mx[i] = max(mx[i], p[i][j]); } } for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j] == 1 && mx[j] > 1) return 0; } } vector<vector<int>> put(n, vector<int>(n)); vector<bool> vis(n); for(int i = 0; i < n; i++) { if(vis[i]) continue; queue<int> q; vector<int> f, s; q.push(i); vis[i] = true; while(!q.empty()) { auto curr = q.front(); f.push_back(curr); q.pop(); for(int next = 0; next < n; next++) { if(p[curr][next] == 1) { if(!vis[next]) { vis[next] = true; q.push(next); } } else { if(!vis[next]) { vis[next] = true; s.push_back(next); } } } } for(int i = 0; i < (int) f.size() - 1; i++) { put[f[i]][f[i + 1]] = 1, put[f[i + 1]][f[i]] = 1; } if(s.empty()) continue; if((int) s.size() == 1) return 0; for(int i = 0; i < (int) s.size() - 1; i++) { put[s[i]][s[i + 1]] = 1, put[s[i + 1]][s[i]] = 1; } put[i][s[0]] = 1, put[s[0]][i] = 1; put[i][s.back()] = 1, put[s.back()][i] = 1; } build(put); }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >&)':
supertrees.cpp:9:21: warning: control reaches end of non-void function [-Wreturn-type]
    9 |     vector<int> mx(n);
      |                     ^
/usr/bin/ld: /tmp/ccNZvYkM.o: in function `construct(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&)':
supertrees.cpp:(.text+0x302): undefined reference to `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&)'
/usr/bin/ld: /tmp/ccROYFvK.o: in function `main':
grader.cpp:(.text.startup+0x39a): undefined reference to `construct(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
collect2: error: ld returned 1 exit status