Submission #1050543

#TimeUsernameProblemLanguageResultExecution timeMemory
1050543amine_arouaFountain Parks (IOI21_parks)C++17
5 / 100
228 ms44700 KiB
#include "parks.h" #include<bits/stdc++.h> using namespace std; vector<vector<int>> adj; vector<bool> vis; void dfs(int i) { if(vis[i]) return; vis[i] = 1; for(auto j : adj[i]) { dfs(j); } } void add_edge(int u , int v) { adj[u].push_back(v); adj[v].push_back(u); } int construct_roads(std::vector<int> x, std::vector<int> y) { int n= (int)x.size(); adj.assign(n , {}); vis.assign(n , 0); vector<int> u , v , a , b; map<pair<int, int> , int> idx; for(int i = 0 ; i <n ; i++) { idx[{x[i] , y[i]}] = i; } for(int i = 0 ; i < n ;i++) { if(idx.count({x[i] + 2 , y[i]})) { u.push_back(i); v.push_back(idx[{x[i] + 2 , y[i]}]); a.push_back(x[i] + 1); b.push_back(y[i]); } if(idx.count({x[i] , y[i] + 2})) { u.push_back(i); v.push_back(idx[{x[i] , y[i] + 2}]); b.push_back(y[i] + 1); if(x[i] == 2) { a.push_back(x[i] - 1); } else { a.push_back(x[i] + 1); } } } for(int i = 0 ; i < (int)u.size() ; i++) { add_edge(u[i] , v[i]); } dfs(0); for(int i = 0 ; i < n ; i++) { if(!vis[i]) { return 0; } } build(u , v , a , b); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...