Submission #1293835

#TimeUsernameProblemLanguageResultExecution timeMemory
1293835123123123World Map (IOI25_worldmap)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<vector<int>> adj; vector<bool> used; vector<int> tour; void DFS(int v) { used[v] = true; tour.push_back(v); for(int to : adj[v]) { if(!used[to]) { DFS(to); tour.push_back(v); } } } vector<vector<int>> create_map(int N, int M, vector<int> A, vector<int> B) { if(M == 0) return {{1}}; adj.assign(N + 1, {}); used.assign(N + 1, false); tour.clear(); for(int i = 0; i < M; i++) { adj[A[i]].push_back(B[i]); adj[B[i]].push_back(A[i]); } vector<bool> vis(N + 1, false); queue<int> q; q.push(1); vis[1] = true; vector<vector<int>> treeAdj(N + 1); while(!q.empty()) { int v = q.front(); q.pop(); for(int to : adj[v]) { if(!vis[to]) { vis[to] = true; q.push(to); treeAdj[v].push_back(to); treeAdj[to].push_back(v); } } } adj = treeAdj; DFS(1); int rows = 4 * N; int cols = 4 * N; vector<vector<int>> mymap(rows, vector<int>(cols, 0)); int curRow = 0; map<int,int> firstOcc; for(int node : tour) { if(!firstOcc.count(node)) { firstOcc[node] = curRow++; int r1 = curRow++; int r2 = curRow++; for(int j = 0; j < cols; j++) mymap[r2][j] = node; int col = 0; for(int nei : adj[node]) { if(col >= cols) break; mymap[r1][col++] = node; if(col >= cols) break; mymap[r1][col++] = nei; } } } for(int i = 1; i < rows; i++) for(int j = 0; j < cols; j++) if(mymap[i][j] == 0) mymap[i][j] = mymap[i-1][j]; return mymap; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector<int> A(M), B(M); for(int i = 0; i < M; i++) cin >> A[i]; for(int i = 0; i < M; i++) cin >> B[i]; vector<vector<int>> grid = create_map(N, M, A, B); for(auto &row : grid) { for(int j = 0; j < (int)row.size(); j++) { cout << row[j]; if(j + 1 < (int)row.size()) cout << " "; } cout << "\n"; } }

Compilation message (stderr)

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