답안 #413108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
413108 2021-05-28T08:56:54 Z BJoozz 기지국 (IOI20_stations) C++17
5 / 100
1101 ms 776 KB
#include "stations.h"

#include<bits/stdc++.h>
using namespace std;
const int MAX=1000+4,M2=5e5+3;

#define pb push_back
vector < int > pr[MAX];
int in[MAX];
int tim=0;
void dfs(int v,int vpa,bool h){
    if(!h) in[v]=tim++;
    for(int u:pr[v])if(u!=vpa)
        dfs(u,v,!h);
    if(h) in[v]=tim++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	for(int i=0;i<n;i++) pr[i].clear();
	tim=0;
	for (int i = 0; i < n-1; i++){
        pr[u[i]].pb(v[i]);
        pr[v[i]].pb(u[i]);
	}
	dfs(0,0,0);

	for (int i = 0; i < n; i++) {
		labels[i] = in[i];
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(s<c[0]){
        if(t<s) return c.back();
        int b=0,e=int(c.size())-2,an=c.back();
        while(b<=e){
            int m=b+e>>1;
            if(t<=c[m]){
                an=c[m];
                b=m+1;
            }
            else e=m-1;
        }
        return an;
	}
	else{
        if(t>s) return c[0];
        int b=1,e=int(c.size())-1,an=c[0];
        while(b<=e){
            int m=b+e>>1;
            if(t>=c[m]){
                an=c[m];b=m+1;

            }
            else e=m-1;
        }
        return an;
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:38:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |             int m=b+e>>1;
      |                   ~^~
stations.cpp:51:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   51 |             int m=b+e>>1;
      |                   ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 613 ms 528 KB Output is correct
2 Correct 608 ms 636 KB Output is correct
3 Correct 1009 ms 400 KB Output is correct
4 Correct 726 ms 512 KB Output is correct
5 Correct 732 ms 516 KB Output is correct
6 Correct 504 ms 520 KB Output is correct
7 Correct 557 ms 512 KB Output is correct
8 Correct 3 ms 424 KB Output is correct
9 Correct 6 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 511 ms 508 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 691 ms 776 KB Output is correct
2 Correct 496 ms 524 KB Output is correct
3 Correct 1101 ms 516 KB Output is correct
4 Correct 687 ms 528 KB Output is correct
5 Correct 730 ms 400 KB Output is correct
6 Correct 643 ms 528 KB Output is correct
7 Correct 537 ms 516 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Incorrect 733 ms 516 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1043 ms 400 KB Output is correct
2 Correct 803 ms 400 KB Output is correct
3 Correct 625 ms 400 KB Output is correct
4 Correct 5 ms 448 KB Output is correct
5 Correct 6 ms 548 KB Output is correct
6 Correct 2 ms 400 KB Output is correct
7 Correct 723 ms 512 KB Output is correct
8 Correct 1073 ms 400 KB Output is correct
9 Correct 852 ms 520 KB Output is correct
10 Correct 623 ms 472 KB Output is correct
11 Incorrect 7 ms 468 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 541 ms 652 KB Output is correct
2 Correct 524 ms 528 KB Output is correct
3 Correct 1013 ms 508 KB Output is correct
4 Correct 777 ms 520 KB Output is correct
5 Correct 728 ms 508 KB Output is correct
6 Correct 586 ms 520 KB Output is correct
7 Correct 626 ms 520 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 5 ms 464 KB Output is correct
10 Correct 2 ms 476 KB Output is correct
11 Incorrect 465 ms 516 KB Wrong query response.
12 Halted 0 ms 0 KB -