# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080134 | 2024-08-29T07:21:13 Z | Faisal_Saqib | Stations (IOI20_stations) | C++17 | 626 ms | 684 KB |
#include "stations.h" #include <vector> #include <bits/stdc++.h> using namespace std; // #define int long long const int N=1e3+100; const int M=1e3; vector<int> ma[N]; vector<int> labels; int val=1; void dfs(int x,int v,int p) { labels[x]=(v*M)+val; val++; for(auto y:ma[x]) { if(y==p)continue; dfs(y,v,x); } } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { labels.resize(n,0); for(int i=0;i<(n);i++)ma[i].clear(),labels[i]=i; for(int i=0;i<(n-1);i++) { ma[u[i]].push_back(v[i]); ma[v[i]].push_back(u[i]); } int mx=0; for(int i=0;i<n;i++) { int sz=ma[i].size(); mx=max(mx,sz); } for(int i=0;i<n;i++) { if(ma[i].size()==mx) { // cout<<"Starting "<<i<<endl; labels[i]=M; int cnt=0; for(auto j:ma[i]) { cnt++; val=1; dfs(j,cnt,i); } break; } } // for(auto j:labels) // { // cout<<j<<' '; // } // cout<<endl; return labels; } int find_next_station(int s, int t, std::vector<int> c) { int pp_t=t-1; if(pp_t%M==0)pp_t=M; if(s==pp_t) return t; // cout<<"AT "<<s<<' '<<t<<endl; int par_t=(t/M); int par_s=(s/M); // cout<<par_s<<' '<<par_t<<endl; if(par_s!=par_t) { int pp=s-1; if(pp%M==0)pp=M; return pp; } if(s<t) return s+1; return s-1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 344 KB | Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=2005 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 596 KB | Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1001 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 371 ms | 684 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 626 ms | 684 KB | Output is correct |
2 | Correct | 459 ms | 684 KB | Output is correct |
3 | Incorrect | 407 ms | 684 KB | Wrong query response. |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 377 ms | 684 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |