# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
219894 | 2020-04-06T16:30:55 Z | DanerZein | Split the Attractions (IOI19_split) | C++14 | 5 ms | 384 KB |
#include "split.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; int vis[100010]; vi pa; vector<vi>G; void dfs(int u,int c){ if(pa.size()==c) return; // cout<<c<<" "<<pa.size()<<endl; pa.push_back(u); vis[u]=1; if(pa.size()==c) return; for(int i=0;i<G[u].size();i++){ if(vis[G[u][i]]==0){ dfs(G[u][i],c); } } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { //vector<vi> G; G.resize(n); vi aux; map<int,int> m; m[a]=1; m[b]=2; m[c]=3; for(int i=0;i<p.size();i++){ int u,v; u=p[i]; v=q[i]; G[v].push_back(u); G[u].push_back(v); } // cout<<"Grafo creado"<<endl; vector<int> r(n,-1); //r.resize(n); map<int,int>:: iterator it; it=m.begin(); it++; pa.clear(); dfs(0,(*it).first); int k=0; sort(pa.begin(),pa.end()); for(int i=0;i<n;i++){ // cout<<pa[i]<<" "; if(pa[k]==i){ r[i]=(*it).second;; k++; } } //cout<<endl; // cout<<(*it).first<<endl; /*for(int i=0;i<r.size();i++){ cout<<r[i]<<" "; } cout<<endl;*/ it=m.begin(); pa.clear(); for(int i=0;i<n;i++){ if(vis[i]==0){ dfs(i,(*it).first); if(pa.size()<(*it).first){ //ca=0; pa.clear(); } else{ break; } } } if(pa.empty()){ for(int i=0;i<n;i++){ r[i]=0; } } else{ map<int,int>:: iterator it1=m.begin(); it1++; it1++; k=0; /*for(int i=0;i<r.size();i++){ cout<<r[i]<<" "; } cout<<endl; for(int i=0;i<pa.size();i++){ cout<<pa[i]<<" "; } cout<<endl;*/ sort(pa.begin(),pa.end()); for(int i=0;i<n;i++){ if(pa[k]==i and k!=pa.size()){ r[i]=(*it).second; k++; } else{ if(r[i]==-1) r[i]=(*it1).second; } } } return r; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 256 KB | answer contains both zero and positive values |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 256 KB | answer contains both zero and positive values |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 256 KB | answer contains both zero and positive values |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | ok, correct split |
2 | Correct | 5 ms | 384 KB | ok, no valid answer |
3 | Incorrect | 5 ms | 256 KB | answer contains both zero and positive values |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 256 KB | answer contains both zero and positive values |
2 | Halted | 0 ms | 0 KB | - |