Submission #1250018

#TimeUsernameProblemLanguageResultExecution timeMemory
1250018testacc11World Map (IOI25_worldmap)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; // -------------------------------------------------- // Problem: World Map // Implementation of create_map for an arbitrary adjacency graph with 1 ≤ N ≤ 40, M edges. // Guaranteed a valid map exists. Here we implement a simple constructive strategy. // -------------------------------------------------- vector<vector<int>> create_map(int N, int M, const vector<int>& A, const vector<int>& B) { // Simple construction: // Use grid of size K = 2 * M (at most 2*N*(N-1)/2 = N*(N-1) ≤ 1560, capped to 240) int K = min(240, 2 * M + 1); if (K < 2) K = 2; vector<vector<int>> C(K, vector<int>(K, 1)); // Place each required adjacency as a vertical pair in its own column for (int i = 0; i < M && i < K; ++i) { C[0][i] = A[i]; C[1][i] = B[i]; } // Ensure every country appears at least once for (int j = 1; j <= N; ++j) { bool used = false; for (int i = 0; i < M && i < K; ++i) { if (A[i] == j || B[i] == j) { used = true; break; } } if (!used) { // place at bottom-right C[K-1][K-1] = j; } } return C; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int T; cin >> T; while (T--) { int N, M; cin >> N >> M; vector<int> A(M), B(M); for (int i = 0; i < M; ++i) { cin >> A[i] >> B[i]; } auto C = create_map(N, M, A, B); int K = C.size(); cout << K << "\n"; cout << K; for (int i = 0; i < K; ++i) { for (int j = 0; j < (int)C[i].size(); ++j) { cout << (j == 0 ? '\n' : ' ') << C[i][j]; } } cout << '\n'; } return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/cc0VXcOS.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccCyhwcU.o:worldmap.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc0VXcOS.o: in function `main':
grader.cpp:(.text.startup+0x635): undefined reference to `create_map(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status