# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145434 | 2019-08-19T20:57:20 Z | JovanK26 | Split the Attractions (IOI19_split) | C++14 | 14 ms | 11260 KB |
#include "split.h" #include<bits/stdc++.h> using namespace std; vector< vector<int> > v(200001); bool cmp(pair<vector<int>,int> i,pair<vector<int>,int> j) { i.first.size()<j.first.size(); } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<int> rez(n); for(int i=0;i<p.size();i++) { v[p[i]].push_back(q[i]); v[q[i]].push_back(p[i]); } if(a==1) { if(b>c)swap(b,c); vector< pair<vector<int>,int> >g(200001); for(int i=0;i<n;i++) { g[i]=make_pair(v[i],i); } bool vis[n]; queue<int> q; for(int i=0;i<n;i++) { rez[i]=0; vis[i]=0; } sort(g.begin(),g.begin()+n,cmp); int start=g[0].second; vis[start]=1; rez[start]=1; int br=0; int node=g[n-1].second; q.push(node); vis[node]=1; while(!q.empty()) { int cur=q.front(); q.pop(); rez[cur]=2; br++; if(br==b)break; for(int i=0;i<v[node].size();i++) { if(!vis[v[node][i]]) { vis[v[node][i]]=1; q.push(v[node][i]); } } } for(int i=0;i<n;i++) { if(rez[i]==0)rez[i]=3; } } return rez; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 11256 KB | ok, correct split |
2 | Correct | 14 ms | 11256 KB | ok, correct split |
3 | Correct | 14 ms | 11260 KB | ok, correct split |
4 | Incorrect | 6 ms | 4984 KB | jury found a solution, contestant did not |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 11256 KB | ok, correct split |
2 | Correct | 12 ms | 11256 KB | ok, correct split |
3 | Incorrect | 12 ms | 11256 KB | invalid split: #1=1, #2=1, #3=3 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4984 KB | jury found a solution, contestant did not |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4984 KB | jury found a solution, contestant did not |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 11256 KB | ok, correct split |
2 | Correct | 14 ms | 11256 KB | ok, correct split |
3 | Correct | 14 ms | 11260 KB | ok, correct split |
4 | Incorrect | 6 ms | 4984 KB | jury found a solution, contestant did not |
5 | Halted | 0 ms | 0 KB | - |