# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
338058 |
2020-12-22T11:40:38 Z |
MvC |
Stations (IOI20_stations) |
C++17 |
|
1017 ms |
1244 KB |
#include "stations.h"
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=1e3+50;
const ll mod=1e9+7;
using namespace std;
int i,d[nmax],in[nmax],out[nmax],tt;
vector<int>g[nmax],rs;
void dfs(int x,int p)
{
d[x]=d[p]^1;
if(d[x])in[x]=tt++;
for(int i=0;i<lun(g[x]);i++)if(g[x][i]!=p)dfs(g[x][i],x);
if(!d[x])out[x]=tt++;
}
vector<int> label(int n,int k,vector<int> u,vector<int> v)
{
rs.clear();
for(i=0;i<n;i++)
{
g[i].clear();
d[i]=0;
}
tt=0;
for(i=0;i<n-1;i++)
{
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
dfs(0,0);
for(i=0;i<n;i++)
{
if(d[i])rs.pb(in[i]);
else rs.pb(out[i]);
}
return rs;
}
int find_next_station(int s,int t,vector<int> c)
{
sort(all(c));
int k=lun(c);
if(s>c.back())
{
for(i=1;i<k-1;i++)if(t>=c[i] && t<c[i+1])return c[i];
if(t>=c[k-1] && t<s)return c[k-1];
return c[0];
}
else
{
for(i=k-2;i>=1;i--)if(t>c[i-1] && t<=c[i])return c[i];
if(t>s && t<=c[0])return c[0];
return c.back();
}
}
/*int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
675 ms |
1072 KB |
Output is correct |
2 |
Correct |
475 ms |
1068 KB |
Output is correct |
3 |
Correct |
902 ms |
936 KB |
Output is correct |
4 |
Correct |
664 ms |
936 KB |
Output is correct |
5 |
Correct |
625 ms |
936 KB |
Output is correct |
6 |
Correct |
439 ms |
1184 KB |
Output is correct |
7 |
Correct |
558 ms |
1096 KB |
Output is correct |
8 |
Correct |
3 ms |
864 KB |
Output is correct |
9 |
Correct |
4 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
593 ms |
736 KB |
Output is correct |
2 |
Correct |
616 ms |
872 KB |
Output is correct |
3 |
Correct |
875 ms |
864 KB |
Output is correct |
4 |
Correct |
683 ms |
876 KB |
Output is correct |
5 |
Correct |
574 ms |
1064 KB |
Output is correct |
6 |
Correct |
493 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
553 ms |
864 KB |
Output is correct |
2 |
Correct |
570 ms |
1068 KB |
Output is correct |
3 |
Correct |
835 ms |
936 KB |
Output is correct |
4 |
Correct |
700 ms |
936 KB |
Output is correct |
5 |
Correct |
761 ms |
864 KB |
Output is correct |
6 |
Correct |
538 ms |
992 KB |
Output is correct |
7 |
Correct |
479 ms |
992 KB |
Output is correct |
8 |
Correct |
3 ms |
976 KB |
Output is correct |
9 |
Correct |
5 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
936 KB |
Output is correct |
11 |
Correct |
693 ms |
736 KB |
Output is correct |
12 |
Correct |
552 ms |
1136 KB |
Output is correct |
13 |
Correct |
559 ms |
1072 KB |
Output is correct |
14 |
Correct |
470 ms |
892 KB |
Output is correct |
15 |
Correct |
55 ms |
928 KB |
Output is correct |
16 |
Correct |
85 ms |
736 KB |
Output is correct |
17 |
Correct |
152 ms |
864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1017 ms |
944 KB |
Output is correct |
2 |
Correct |
691 ms |
864 KB |
Output is correct |
3 |
Correct |
730 ms |
864 KB |
Output is correct |
4 |
Correct |
3 ms |
944 KB |
Output is correct |
5 |
Correct |
4 ms |
736 KB |
Output is correct |
6 |
Correct |
2 ms |
864 KB |
Output is correct |
7 |
Correct |
584 ms |
736 KB |
Output is correct |
8 |
Correct |
988 ms |
896 KB |
Output is correct |
9 |
Correct |
761 ms |
1164 KB |
Output is correct |
10 |
Correct |
599 ms |
944 KB |
Output is correct |
11 |
Correct |
7 ms |
944 KB |
Output is correct |
12 |
Correct |
7 ms |
944 KB |
Output is correct |
13 |
Correct |
6 ms |
736 KB |
Output is correct |
14 |
Correct |
5 ms |
944 KB |
Output is correct |
15 |
Correct |
3 ms |
736 KB |
Output is correct |
16 |
Correct |
497 ms |
864 KB |
Output is correct |
17 |
Correct |
481 ms |
936 KB |
Output is correct |
18 |
Correct |
537 ms |
944 KB |
Output is correct |
19 |
Correct |
531 ms |
864 KB |
Output is correct |
20 |
Correct |
566 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
509 ms |
1072 KB |
Output is correct |
2 |
Correct |
445 ms |
1072 KB |
Output is correct |
3 |
Correct |
833 ms |
936 KB |
Output is correct |
4 |
Correct |
621 ms |
936 KB |
Output is correct |
5 |
Correct |
558 ms |
936 KB |
Output is correct |
6 |
Correct |
428 ms |
992 KB |
Output is correct |
7 |
Correct |
415 ms |
1244 KB |
Output is correct |
8 |
Correct |
3 ms |
864 KB |
Output is correct |
9 |
Correct |
4 ms |
864 KB |
Output is correct |
10 |
Correct |
2 ms |
776 KB |
Output is correct |
11 |
Correct |
425 ms |
864 KB |
Output is correct |
12 |
Correct |
534 ms |
1212 KB |
Output is correct |
13 |
Correct |
862 ms |
736 KB |
Output is correct |
14 |
Correct |
643 ms |
828 KB |
Output is correct |
15 |
Correct |
585 ms |
936 KB |
Output is correct |
16 |
Correct |
442 ms |
880 KB |
Output is correct |
17 |
Correct |
575 ms |
864 KB |
Output is correct |
18 |
Correct |
426 ms |
996 KB |
Output is correct |
19 |
Correct |
462 ms |
1120 KB |
Output is correct |
20 |
Correct |
429 ms |
1024 KB |
Output is correct |
21 |
Correct |
56 ms |
864 KB |
Output is correct |
22 |
Correct |
75 ms |
900 KB |
Output is correct |
23 |
Correct |
108 ms |
992 KB |
Output is correct |
24 |
Correct |
7 ms |
864 KB |
Output is correct |
25 |
Correct |
5 ms |
944 KB |
Output is correct |
26 |
Correct |
5 ms |
736 KB |
Output is correct |
27 |
Correct |
3 ms |
736 KB |
Output is correct |
28 |
Correct |
2 ms |
736 KB |
Output is correct |
29 |
Correct |
479 ms |
864 KB |
Output is correct |
30 |
Correct |
480 ms |
936 KB |
Output is correct |
31 |
Correct |
501 ms |
864 KB |
Output is correct |
32 |
Correct |
509 ms |
992 KB |
Output is correct |
33 |
Correct |
508 ms |
736 KB |
Output is correct |
34 |
Correct |
343 ms |
1084 KB |
Output is correct |
35 |
Correct |
483 ms |
992 KB |
Output is correct |
36 |
Correct |
441 ms |
864 KB |
Output is correct |
37 |
Correct |
519 ms |
992 KB |
Output is correct |
38 |
Correct |
444 ms |
1220 KB |
Output is correct |
39 |
Correct |
517 ms |
1216 KB |
Output is correct |
40 |
Correct |
433 ms |
1164 KB |
Output is correct |
41 |
Correct |
458 ms |
1140 KB |
Output is correct |
42 |
Correct |
62 ms |
864 KB |
Output is correct |
43 |
Correct |
109 ms |
872 KB |
Output is correct |
44 |
Correct |
163 ms |
1100 KB |
Output is correct |
45 |
Correct |
219 ms |
1108 KB |
Output is correct |
46 |
Correct |
295 ms |
1004 KB |
Output is correct |
47 |
Correct |
284 ms |
1120 KB |
Output is correct |
48 |
Correct |
62 ms |
1088 KB |
Output is correct |
49 |
Correct |
69 ms |
864 KB |
Output is correct |