Submission #433012

# Submission time Handle Problem Language Result Execution time Memory
433012 2021-06-18T17:35:14 Z cheetose Stations (IOI20_stations) C++17
100 / 100
922 ms 760 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin())
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<ld> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

#include "stations.h"
Vi vv[1000];
Vi labels;
int cc;
void dfs(int N,int p=-1,int d=0){
	if(d==0)labels[N]=cc++;
	for(int next:vv[N]){
		if(next==p)continue;
		dfs(next,N,d^1);
	}
	if(d==1)labels[N]=cc++;
}
Vi label(int n, int k, Vi u, Vi v) {
	fup(i,0,n-1,1)vv[i].clear();
	cc=0;
	labels=Vi(n);
	fup(i,0,n-2,1){
		int x=u[i],y=v[i];
		vv[x].pb(y);
		vv[y].pb(x);
	}
	dfs(0);
	return labels;
}

int find_next_station(int s, int t, Vi c) {
	int N=c.size();
	if(s<c[0]){
		int pr=s;
		fup(i,0,N-2,1){
			if(pr+1<=t && t<=c[i])return c[i];
			pr=c[i];
		}
		return c.back();
	}else{
		int pr=s;
		fdn(i,N-1,1,1){
			if(c[i]<=t && t<=pr-1)return c[i];
			pr=c[i];
		}
		return c[0];
	}
}

Compilation message

stations.cpp: In function 'Vi label(int, int, Vi, Vi)':
stations.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
stations.cpp:56:2: note: in expansion of macro 'fup'
   56 |  fup(i,0,n-1,1)vv[i].clear();
      |  ^~~
stations.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
stations.cpp:59:2: note: in expansion of macro 'fup'
   59 |  fup(i,0,n-2,1){
      |  ^~~
stations.cpp: In function 'int find_next_station(int, int, Vi)':
stations.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
stations.cpp:72:3: note: in expansion of macro 'fup'
   72 |   fup(i,0,N-2,1){
      |   ^~~
stations.cpp:11:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   11 | #define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
      |                              ^
stations.cpp:79:3: note: in expansion of macro 'fdn'
   79 |   fdn(i,N-1,1,1){
      |   ^~~
# Verdict Execution time Memory Grader output
1 Correct 568 ms 632 KB Output is correct
2 Correct 470 ms 632 KB Output is correct
3 Correct 894 ms 492 KB Output is correct
4 Correct 660 ms 416 KB Output is correct
5 Correct 550 ms 400 KB Output is correct
6 Correct 479 ms 632 KB Output is correct
7 Correct 447 ms 516 KB Output is correct
8 Correct 3 ms 476 KB Output is correct
9 Correct 4 ms 464 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 483 ms 520 KB Output is correct
2 Correct 503 ms 528 KB Output is correct
3 Correct 883 ms 496 KB Output is correct
4 Correct 671 ms 528 KB Output is correct
5 Correct 618 ms 512 KB Output is correct
6 Correct 464 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 553 ms 528 KB Output is correct
2 Correct 450 ms 712 KB Output is correct
3 Correct 864 ms 556 KB Output is correct
4 Correct 699 ms 400 KB Output is correct
5 Correct 572 ms 516 KB Output is correct
6 Correct 456 ms 760 KB Output is correct
7 Correct 455 ms 512 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 3 ms 552 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 576 ms 528 KB Output is correct
12 Correct 445 ms 620 KB Output is correct
13 Correct 457 ms 636 KB Output is correct
14 Correct 415 ms 508 KB Output is correct
15 Correct 56 ms 400 KB Output is correct
16 Correct 64 ms 528 KB Output is correct
17 Correct 103 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 887 ms 400 KB Output is correct
2 Correct 697 ms 516 KB Output is correct
3 Correct 595 ms 400 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 7 ms 472 KB Output is correct
6 Correct 2 ms 476 KB Output is correct
7 Correct 586 ms 520 KB Output is correct
8 Correct 803 ms 404 KB Output is correct
9 Correct 655 ms 540 KB Output is correct
10 Correct 557 ms 400 KB Output is correct
11 Correct 7 ms 548 KB Output is correct
12 Correct 6 ms 468 KB Output is correct
13 Correct 6 ms 480 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 502 ms 400 KB Output is correct
17 Correct 468 ms 400 KB Output is correct
18 Correct 504 ms 400 KB Output is correct
19 Correct 547 ms 400 KB Output is correct
20 Correct 501 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 538 ms 532 KB Output is correct
2 Correct 410 ms 520 KB Output is correct
3 Correct 922 ms 400 KB Output is correct
4 Correct 690 ms 508 KB Output is correct
5 Correct 587 ms 400 KB Output is correct
6 Correct 429 ms 632 KB Output is correct
7 Correct 421 ms 528 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 6 ms 468 KB Output is correct
10 Correct 2 ms 476 KB Output is correct
11 Correct 463 ms 564 KB Output is correct
12 Correct 579 ms 504 KB Output is correct
13 Correct 866 ms 520 KB Output is correct
14 Correct 687 ms 400 KB Output is correct
15 Correct 584 ms 512 KB Output is correct
16 Correct 445 ms 508 KB Output is correct
17 Correct 561 ms 508 KB Output is correct
18 Correct 430 ms 604 KB Output is correct
19 Correct 459 ms 640 KB Output is correct
20 Correct 415 ms 504 KB Output is correct
21 Correct 65 ms 400 KB Output is correct
22 Correct 70 ms 528 KB Output is correct
23 Correct 97 ms 528 KB Output is correct
24 Correct 5 ms 468 KB Output is correct
25 Correct 6 ms 468 KB Output is correct
26 Correct 4 ms 468 KB Output is correct
27 Correct 4 ms 476 KB Output is correct
28 Correct 2 ms 476 KB Output is correct
29 Correct 492 ms 528 KB Output is correct
30 Correct 450 ms 400 KB Output is correct
31 Correct 546 ms 400 KB Output is correct
32 Correct 513 ms 400 KB Output is correct
33 Correct 495 ms 404 KB Output is correct
34 Correct 315 ms 532 KB Output is correct
35 Correct 422 ms 748 KB Output is correct
36 Correct 412 ms 624 KB Output is correct
37 Correct 479 ms 632 KB Output is correct
38 Correct 482 ms 628 KB Output is correct
39 Correct 485 ms 624 KB Output is correct
40 Correct 380 ms 612 KB Output is correct
41 Correct 444 ms 636 KB Output is correct
42 Correct 51 ms 576 KB Output is correct
43 Correct 127 ms 528 KB Output is correct
44 Correct 134 ms 532 KB Output is correct
45 Correct 156 ms 604 KB Output is correct
46 Correct 327 ms 508 KB Output is correct
47 Correct 297 ms 608 KB Output is correct
48 Correct 67 ms 660 KB Output is correct
49 Correct 57 ms 724 KB Output is correct