# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388186 | 2021-04-10T12:44:23 Z | Supersonic | Stations (IOI20_stations) | C++14 | 1509 ms | 2097156 KB |
#include "stations.h" #include <bits/stdc++.h> using namespace std; int c[1001];set<int> a[1001];int l[1001]; int ch(int k,int p){ int t=a[k].size()-1;for(auto i:a[k])if(i!=p)t+=ch(i,k); //if(k==0)for(auto i:a[k])cerr<<i<<'=';cout<<endl; c[k]=t;return t; } void as(int k,int p,int v,int g){ //cerr<<k<<' '<<p<<' '<<v<<' '<<g<<endl; int j=v;l[k]=v; for(auto i:a[k])if(i!=p){j+=(c[i]+1)*g;as(i,k,j,g*(-1));} } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { for(int i=0;i<n-1;i++){ a[u[i]].insert(v[i]); a[v[i]].insert(u[i]); } int r=ch(0,-1);as(0,-1,0,1); //for(int i=0;i<n;i++){cerr<<i<<'-'<<c[i]<<endl;} vector<int> f;for(int i=0;i<n;i++){f.push_back(l[i]);//cerr<<i<<':'<<l[i]<<endl; } return f; } int find_next_station(int s, int t, std::vector<int> c) { int n=c.size(); //cerr<<s<<' '<<t<<endl;for(auto i:c)cerr<<i<<'-';cerr<<endl; if(s<c[0]){ for(int i=0;i<n-1;i++){if(t==c[i])return t;if(c[i]>t)return c[i];} return c[n-1]; } else{ for(int i=n-1;i>=1;i--){if(t==c[i])return t;if(t>c[i])return c[i];} return c[0]; } exit(1); return c[0]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1408 ms | 2097156 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 415 ms | 664 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1498 ms | 2097156 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 783 ms | 672 KB | Output is correct |
2 | Runtime error | 1058 ms | 2097156 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1509 ms | 2097156 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |