제출 #1293820

#제출 시각아이디문제언어결과실행 시간메모리
1293820123123123세계 지도 (IOI25_worldmap)C++20
컴파일 에러
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]); } // BFS to build MST 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++; // alternating row int r2 = curRow++; // full node row // Full row with node for (int j = 0; j < cols; j++) mymap[r2][j] = node; // Alternating row: node + neighbors int col = 0; for (int nei : adj[node]) { if (col >= cols) break; mymap[r1][col++] = node; if (col >= cols) break; mymap[r1][col++] = nei; } } } // Fill remaining zeros by copying the previous row 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() { 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 < row.size(); j++) { cout << row[j]; if (j + 1 < row.size()) cout << " "; } cout << "\n"; } }

컴파일 시 표준 에러 (stderr) 메시지

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