Submission #1261415

#TimeUsernameProblemLanguageResultExecution timeMemory
1261415riddlesWorld Map (IOI25_worldmap)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef map<ll, ll> mp; typedef pair<ll, ll> pll; typedef queue<ll> qi; typedef vector<ll> vi; typedef vector <vi> vvi; typedef vector <pll> vpl; typedef vector <string> vs; #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define F first #define S second #define pb push_back #define all(x) begin(x), end(x) #define V vector void setIO(string name = "") { ios_base::sync_with_stdio(0); cin.tie(0); if ((ll)(name.size())) { freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } } V<int>adj[41]; V<int>t[41]; bool vis[41]; V<int>v; void dfs(int n) { vis[n]=true; for (auto u:adj[n]) { if (!vis[u]) { t[u].pb(n); t[n].pb(u); dfs(u); } } } void dfs1(int n,int p) { v.pb(n); for (auto u:t[n]) { if (u==p)continue; dfs1(u,n); } if (p!=-1) { v.pb(p); } } void solve(){ ll N=5, M=4; vector<int> A={1, 2, 3, 4}; vector<int> B={2, 3, 4, 5}; //if(N == 1) return {{1}}; vector<vector<int>> adj(N + 1); 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); vector<int> tour; auto dfs = [&](int v, auto &&dfs) -> void { tour.push_back(v); vis[v] = 1; for(auto u: adj[v]) { if(vis[u]) continue; dfs(u, dfs); tour.push_back(v); } }; dfs(1, dfs); tour.resize(2 * N, 1); fill(all(vis), 0); vector<vector<int>> ans(4 * N, vector<int>(4 * N)); int r = 0; for(int i = 0; i < 2 * N; ++i) { int v = tour[i]; fill(all(ans[r]), v), r++; if(vis[v]) continue; vis[v] = 1; fill(all(ans[r]), v); int c = 0; for(auto u: adj[v]) ans[r][c] = u, c += 2; r++; fill(all(ans[r]), v), r++; } for(ll i=0; i<4*N; i++){ for(ll j=0; j<4*N; j++) cout<<ans[i][j]<<' '; cout<<'\n'; } } int main(){ setIO(""); ll k=1; //cin>>k; while (k--) solve(); return 0; }

Compilation message (stderr)

worldmap.cpp: In function 'void setIO(std::string)':
worldmap.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen((name + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
worldmap.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccZRmjns.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccloMU8G.o:worldmap.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccZRmjns.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