# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
320600 | 2020-11-09T08:27:16 Z | kshitij_sodani | Stations (IOI20_stations) | C++14 | 901 ms | 1076 KB |
#include <bits/stdc++.h> using namespace std; typedef long long llo; #define mp make_pair #define pb push_back #define a first #define b second #define endl '\n' #include "stations.h" vector<int> adj[1001]; int co=0; int st[1001]; int endd[1001]; int levv[1001]; int nn; void dfs(int no,int par=-1,int levv=0){ st[no]=co; co++; for(auto j:adj[no]){ if(j!=par){ dfs(j,no,levv+1); } } if(levv%2==1){ st[no]=co; } co++; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { nn=n; for(int i=0;i<n;i++){ adj[i].clear(); } co=0; for(int i=0;i<n-1;i++){ adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } dfs(0); vector<int> ans; for(int i=0;i<n;i++){ ans.pb(st[i]); // cout<<st[i]; } //cout<<endl; return ans; } int find_next_station(int s, int t, std::vector<int> c) { if(c.size()==1){ return c[0]; } sort(c.begin(),c.end()); /*vector<int> cc; for(auto j:c){ if(j>=1000){ cc.pb(j-1000); } else{ cc.pb(j); } }*/ if(s<c[0]){ int pre=s-1; for(int i=0;i<c.size()-1;i++){ int la=0; if(i==0){ la=s; } else{ la=c[i-1]+1; } if(t<=c[i] and t>=la){ return c[i]; } } return c.back(); } else{ for(int i=c.size()-1;i>0;i--){ int la=0; if(i==c.size()-1){ la=s; } else{ la=c[i+1]-1; } if(t<=la and t>=c[i]){ return c[i]; } } return c.back(); } return c[0]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 492 KB | Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 472 KB | Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 587 ms | 1032 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 901 ms | 1076 KB | Output is correct |
2 | Incorrect | 785 ms | 864 KB | Wrong query response. |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 543 ms | 992 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |