# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
350728 |
2021-01-19T07:52:28 Z |
Kerim |
Stations (IOI20_stations) |
C++17 |
|
1043 ms |
1368 KB |
#include "stations.h"
#include "bits/stdc++.h"
#define MAXN 1009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int T,n;
vector<int>adj[MAXN],labels;
void dfs(int nd,int pr,int lvl){
if(!lvl)labels[nd]=T++;
tr(it,adj[nd])
if(*it!=pr)
dfs(*it,nd,lvl^1);
if(lvl)labels[nd]=T++;
}
vector<int> label(int N, int k,vector<int> u, std::vector<int> v) {
n=N;T=0;labels.clear();
labels.resize(n);
for(int i=0;i<n;i++)adj[i].clear();
for(int i=0;i<n-1;i++){
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
}
dfs(0,-1,0);
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
sort(all(c));int m=int(c.size());
if(!s){
tr(it,c)
if(t<=*it)
return *it;
}
if(s<c[0]){
int in=s,out=c[m-1]-1;
if(in<t and t<=out){
tr(it,c)
if(t<=*it)
return *it;
}
return c.back();
}
else{
int in=c[0]+1,out=s;
if(in<=t and t<out){
for(int i=m-1;i>=0;i--)
if(c[i]<=t)
return c[i];
}
return c[0];
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
541 ms |
1076 KB |
Output is correct |
2 |
Correct |
509 ms |
1120 KB |
Output is correct |
3 |
Correct |
885 ms |
736 KB |
Output is correct |
4 |
Correct |
732 ms |
864 KB |
Output is correct |
5 |
Correct |
673 ms |
952 KB |
Output is correct |
6 |
Correct |
536 ms |
1084 KB |
Output is correct |
7 |
Correct |
478 ms |
992 KB |
Output is correct |
8 |
Correct |
3 ms |
952 KB |
Output is correct |
9 |
Correct |
5 ms |
736 KB |
Output is correct |
10 |
Correct |
1 ms |
904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
527 ms |
864 KB |
Output is correct |
2 |
Correct |
573 ms |
864 KB |
Output is correct |
3 |
Correct |
977 ms |
1120 KB |
Output is correct |
4 |
Correct |
731 ms |
864 KB |
Output is correct |
5 |
Correct |
730 ms |
864 KB |
Output is correct |
6 |
Correct |
502 ms |
920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
590 ms |
1024 KB |
Output is correct |
2 |
Correct |
489 ms |
1080 KB |
Output is correct |
3 |
Correct |
1043 ms |
864 KB |
Output is correct |
4 |
Correct |
659 ms |
952 KB |
Output is correct |
5 |
Correct |
597 ms |
992 KB |
Output is correct |
6 |
Correct |
501 ms |
1012 KB |
Output is correct |
7 |
Correct |
429 ms |
992 KB |
Output is correct |
8 |
Correct |
3 ms |
952 KB |
Output is correct |
9 |
Correct |
4 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
992 KB |
Output is correct |
11 |
Correct |
566 ms |
896 KB |
Output is correct |
12 |
Correct |
465 ms |
992 KB |
Output is correct |
13 |
Correct |
449 ms |
1216 KB |
Output is correct |
14 |
Correct |
455 ms |
1028 KB |
Output is correct |
15 |
Correct |
56 ms |
864 KB |
Output is correct |
16 |
Correct |
67 ms |
748 KB |
Output is correct |
17 |
Correct |
104 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
888 ms |
1108 KB |
Output is correct |
2 |
Correct |
643 ms |
1024 KB |
Output is correct |
3 |
Correct |
563 ms |
952 KB |
Output is correct |
4 |
Correct |
3 ms |
736 KB |
Output is correct |
5 |
Correct |
4 ms |
960 KB |
Output is correct |
6 |
Correct |
1 ms |
736 KB |
Output is correct |
7 |
Correct |
594 ms |
992 KB |
Output is correct |
8 |
Correct |
931 ms |
736 KB |
Output is correct |
9 |
Correct |
790 ms |
1020 KB |
Output is correct |
10 |
Correct |
722 ms |
864 KB |
Output is correct |
11 |
Correct |
6 ms |
736 KB |
Output is correct |
12 |
Correct |
8 ms |
748 KB |
Output is correct |
13 |
Correct |
6 ms |
832 KB |
Output is correct |
14 |
Correct |
4 ms |
952 KB |
Output is correct |
15 |
Correct |
2 ms |
864 KB |
Output is correct |
16 |
Correct |
522 ms |
864 KB |
Output is correct |
17 |
Correct |
540 ms |
952 KB |
Output is correct |
18 |
Correct |
552 ms |
952 KB |
Output is correct |
19 |
Correct |
562 ms |
864 KB |
Output is correct |
20 |
Correct |
500 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
621 ms |
1368 KB |
Output is correct |
2 |
Correct |
461 ms |
864 KB |
Output is correct |
3 |
Correct |
952 ms |
864 KB |
Output is correct |
4 |
Correct |
807 ms |
836 KB |
Output is correct |
5 |
Correct |
673 ms |
952 KB |
Output is correct |
6 |
Correct |
470 ms |
992 KB |
Output is correct |
7 |
Correct |
504 ms |
1248 KB |
Output is correct |
8 |
Correct |
3 ms |
736 KB |
Output is correct |
9 |
Correct |
4 ms |
888 KB |
Output is correct |
10 |
Correct |
2 ms |
864 KB |
Output is correct |
11 |
Correct |
529 ms |
992 KB |
Output is correct |
12 |
Correct |
748 ms |
864 KB |
Output is correct |
13 |
Correct |
930 ms |
736 KB |
Output is correct |
14 |
Correct |
672 ms |
1080 KB |
Output is correct |
15 |
Correct |
673 ms |
864 KB |
Output is correct |
16 |
Correct |
468 ms |
900 KB |
Output is correct |
17 |
Correct |
585 ms |
864 KB |
Output is correct |
18 |
Correct |
477 ms |
1120 KB |
Output is correct |
19 |
Correct |
621 ms |
1204 KB |
Output is correct |
20 |
Correct |
448 ms |
864 KB |
Output is correct |
21 |
Correct |
63 ms |
736 KB |
Output is correct |
22 |
Correct |
77 ms |
864 KB |
Output is correct |
23 |
Correct |
129 ms |
864 KB |
Output is correct |
24 |
Correct |
7 ms |
864 KB |
Output is correct |
25 |
Correct |
5 ms |
736 KB |
Output is correct |
26 |
Correct |
4 ms |
864 KB |
Output is correct |
27 |
Correct |
5 ms |
736 KB |
Output is correct |
28 |
Correct |
2 ms |
960 KB |
Output is correct |
29 |
Correct |
566 ms |
748 KB |
Output is correct |
30 |
Correct |
677 ms |
992 KB |
Output is correct |
31 |
Correct |
585 ms |
864 KB |
Output is correct |
32 |
Correct |
593 ms |
864 KB |
Output is correct |
33 |
Correct |
657 ms |
864 KB |
Output is correct |
34 |
Correct |
357 ms |
992 KB |
Output is correct |
35 |
Correct |
457 ms |
1120 KB |
Output is correct |
36 |
Correct |
475 ms |
1208 KB |
Output is correct |
37 |
Correct |
485 ms |
1128 KB |
Output is correct |
38 |
Correct |
513 ms |
1236 KB |
Output is correct |
39 |
Correct |
515 ms |
1056 KB |
Output is correct |
40 |
Correct |
585 ms |
996 KB |
Output is correct |
41 |
Correct |
499 ms |
1256 KB |
Output is correct |
42 |
Correct |
65 ms |
900 KB |
Output is correct |
43 |
Correct |
108 ms |
864 KB |
Output is correct |
44 |
Correct |
138 ms |
868 KB |
Output is correct |
45 |
Correct |
167 ms |
864 KB |
Output is correct |
46 |
Correct |
319 ms |
892 KB |
Output is correct |
47 |
Correct |
315 ms |
1116 KB |
Output is correct |
48 |
Correct |
77 ms |
992 KB |
Output is correct |
49 |
Correct |
75 ms |
1096 KB |
Output is correct |