제출 #1293693

#제출 시각아이디문제언어결과실행 시간메모리
1293693tschav_세계 지도 (IOI25_worldmap)C++20
컴파일 에러
0 ms0 KiB
#include "worldmap.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> create_map(int n, int m, vector<int> A, vector<int> B) { vector<vector<int>> adj; adj.resize(n+1,vector<int>{}); for(int i = 0; i < m; ++i) { adj[A[i]].emplace_back(B[i]); adj[B[i]].emplace_back(A[i]); } if(m == 0){ return vector<vector<int>>{vector<int>{1}}; } vector<int> row; vector<bool> vis(n+1,false); int C = 0 ; auto dfs = [&](int ind, auto &&dfs) -> void { vis[ind]=true; ++C; row.push_back(ind); for(auto &u : adj[ind]) { if(vis[u] ) continue; dfs(u,dfs); if(C!=n)row.push_back(ind); } }; dfs(1, dfs); // for(int i = 0; i < row.size();++i){ // cerr << row[i] << " "; // } map<int,int>freq; int sz = 1; for(int i = 1; i < row.size();++i){ if(freq[row[i]]){ ++sz; }else{sz+=2;} ++freq[row[i]]; } vector<vector<int>> ans(sz, vector<int>(sz, 1)); vector<bool> F(n+1,false); int last= 0; int L = 0; int lastt = 0; int par = 1; if(true){ queue<int> Q; int u= row[L]; for(auto &v : adj[u]){ Q.push(v); } for(int i = 0; i < sz; ++i){ if((i & 1) == par or Q.empty()){ ans[i][0] = u; }else{ ans[i][0] = Q.front(); Q.pop(); } } F[u]=true; } ++L; for(int i = 1; i < sz; ++i){ int u = row[L]; if(F[u]){ lastt = i; for(int j = 0; j < sz;++ j){ ans[j][i] = u; } ++L; continue; } if(i==lastt+1){ int w = row[L-1]; //cerr << endl; //cerr << u << " " << w; for(int j = 0; j < sz;++ j){ if((j & 1) == par){ ans[j][i] = u; }else ans[j][i] = w; } par ^= 1; continue; } if( i == lastt+2){ queue<int> Q; for(auto &v : adj[u]){ Q.push(v); } for(int j = 0; j < sz; ++j){ if((j & 1) == par or Q.empty()){ ans[j][i] = u; }else{ ans[j][i] = Q.front(); Q.pop(); } } F[u] = true; lastt+=2; ++L; } } // for(int i = 0; i < row.size(); ++i) { // int u = row[i]; // queue<int> Q; // for(auto &v : adj[u]){ // Q.push(v); // } // if(F[u]){ // for(int j = 0; j < sz;++j)ans[j][last]=u; // ++last; // }else{ // int p1 = last; // int p2 = last+1; // int p3 = last+2; // for(int j = 0; j < sz; ++j){ // if(j & 1 or Q.empty()){ // ans[j][p1]=ans[j][p2]=ans[j][p3]=u; // }else{ // ans[j][p1]=ans[j][p3]=u; // ans[j][p2]=Q.front(); // Q.pop(); // } // } // last+=3; // } // F[u]=true; // } return ans; } int main() { auto ans = create_map(6,9,vector<int>{1,2,3,4,5,6,1,1,2},vector<int>{2,3,4,5,6,1,3,4,5}); for(auto &v: ans){ for(auto &i: v){ cout << i << " "; } cout << endl; } }

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

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