Submission #1293823

#TimeUsernameProblemLanguageResultExecution timeMemory
1293823123123123World Map (IOI25_worldmap)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<vector<int>> adj; vector<vector<int>> mstAdj; vector<bool> used; vector<int> tour; void DFS(int v) { used[v] = true; tour.push_back(v); for (int to : mstAdj[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 vector<vector<int>>(1, vector<int>(1, 1)); } adj.assign(N + 1, {}); mstAdj.assign(N + 1, {}); used.assign(N + 1, false); for (int i = 0; i < M; i++) { adj[A[i]].push_back(B[i]); adj[B[i]].push_back(A[i]); } vector<bool> visited(N + 1, false); queue<int> q; q.push(1); visited[1] = true; while (!q.empty()) { int v = q.front(); q.pop(); for (int to : adj[v]) { if (!visited[to]) { visited[to] = true; q.push(to); mstAdj[v].push_back(to); mstAdj[to].push_back(v); } } } 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; 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/cc2E7blB.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccaBsLlA.o:worldmap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status