답안 #750386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750386 2023-05-29T12:57:49 Z mohav48173 기지국 (IOI20_stations) C++14
100 / 100
961 ms 788 KB
#include "stations.h"///15:49
#include<bits/stdc++.h>
using namespace std;
vector<int>cur;
vector<int>a[1001];
int counter;
void dfs(int n,int par=-1,int depth=0) {
    if(depth%2==0)cur[n]=counter++;
    for(int i:a[n]) {
        if(i!=par)dfs(i,n,depth+1);
    }
    if(depth%2==1)cur[n]=counter++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    cur=vector<int>(n,0);
    for(int i=0;i<n;i++){a[i].clear();}
    counter=0;
    for(int i=0;i<n-1;i++) {
        a[u[i]].push_back(v[i]);
        a[v[i]].push_back(u[i]);
    }
    dfs(0);
    return cur;
}

int find_next_station(int s, int t, vector<int> c) {
    if(c.size()==1)return c[0];
    int par=-1;
    if(s<c[0])par=c[c.size()-1];
    else par=c[0];
    c.erase(find(c.begin(),c.end(),par));
    if(par<s) {
        if(t>s || t<c[0])return par;
        for(int i=0;i<c.size();i++) {
            if(i==c.size()-1 || c[i+1]>t)return c[i];
        }
    } else {
        if(t<s || t>c[c.size()-1])return par;
        for(int i=0;i<c.size();i++) {
            if(t<=c[i])return c[i];
        }
    }
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i=0;i<c.size();i++) {
      |                     ~^~~~~~~~~
stations.cpp:35:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             if(i==c.size()-1 || c[i+1]>t)return c[i];
      |                ~^~~~~~~~~~~~
stations.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int i=0;i<c.size();i++) {
      |                     ~^~~~~~~~~
stations.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 515 ms 648 KB Output is correct
2 Correct 451 ms 676 KB Output is correct
3 Correct 821 ms 428 KB Output is correct
4 Correct 702 ms 416 KB Output is correct
5 Correct 566 ms 528 KB Output is correct
6 Correct 405 ms 548 KB Output is correct
7 Correct 446 ms 528 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 500 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 423 ms 576 KB Output is correct
2 Correct 537 ms 548 KB Output is correct
3 Correct 900 ms 416 KB Output is correct
4 Correct 681 ms 420 KB Output is correct
5 Correct 473 ms 416 KB Output is correct
6 Correct 508 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 538 ms 676 KB Output is correct
2 Correct 447 ms 664 KB Output is correct
3 Correct 926 ms 508 KB Output is correct
4 Correct 700 ms 528 KB Output is correct
5 Correct 582 ms 416 KB Output is correct
6 Correct 432 ms 656 KB Output is correct
7 Correct 463 ms 512 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 5 ms 500 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 615 ms 596 KB Output is correct
12 Correct 488 ms 664 KB Output is correct
13 Correct 424 ms 784 KB Output is correct
14 Correct 448 ms 528 KB Output is correct
15 Correct 45 ms 492 KB Output is correct
16 Correct 49 ms 600 KB Output is correct
17 Correct 88 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 774 ms 416 KB Output is correct
2 Correct 569 ms 532 KB Output is correct
3 Correct 480 ms 420 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 0 ms 500 KB Output is correct
7 Correct 656 ms 528 KB Output is correct
8 Correct 793 ms 420 KB Output is correct
9 Correct 614 ms 416 KB Output is correct
10 Correct 618 ms 528 KB Output is correct
11 Correct 5 ms 500 KB Output is correct
12 Correct 6 ms 500 KB Output is correct
13 Correct 5 ms 492 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 527 ms 528 KB Output is correct
17 Correct 554 ms 528 KB Output is correct
18 Correct 495 ms 560 KB Output is correct
19 Correct 482 ms 420 KB Output is correct
20 Correct 490 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 490 ms 656 KB Output is correct
2 Correct 382 ms 664 KB Output is correct
3 Correct 876 ms 420 KB Output is correct
4 Correct 743 ms 416 KB Output is correct
5 Correct 522 ms 532 KB Output is correct
6 Correct 434 ms 544 KB Output is correct
7 Correct 334 ms 532 KB Output is correct
8 Correct 3 ms 500 KB Output is correct
9 Correct 4 ms 500 KB Output is correct
10 Correct 0 ms 496 KB Output is correct
11 Correct 429 ms 544 KB Output is correct
12 Correct 522 ms 548 KB Output is correct
13 Correct 961 ms 420 KB Output is correct
14 Correct 608 ms 536 KB Output is correct
15 Correct 508 ms 420 KB Output is correct
16 Correct 471 ms 544 KB Output is correct
17 Correct 603 ms 524 KB Output is correct
18 Correct 505 ms 648 KB Output is correct
19 Correct 475 ms 744 KB Output is correct
20 Correct 427 ms 516 KB Output is correct
21 Correct 45 ms 472 KB Output is correct
22 Correct 63 ms 572 KB Output is correct
23 Correct 90 ms 664 KB Output is correct
24 Correct 7 ms 492 KB Output is correct
25 Correct 3 ms 500 KB Output is correct
26 Correct 5 ms 492 KB Output is correct
27 Correct 4 ms 608 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 392 ms 504 KB Output is correct
30 Correct 471 ms 416 KB Output is correct
31 Correct 526 ms 596 KB Output is correct
32 Correct 484 ms 420 KB Output is correct
33 Correct 418 ms 416 KB Output is correct
34 Correct 286 ms 660 KB Output is correct
35 Correct 488 ms 648 KB Output is correct
36 Correct 429 ms 652 KB Output is correct
37 Correct 442 ms 620 KB Output is correct
38 Correct 479 ms 520 KB Output is correct
39 Correct 432 ms 788 KB Output is correct
40 Correct 393 ms 636 KB Output is correct
41 Correct 458 ms 648 KB Output is correct
42 Correct 66 ms 528 KB Output is correct
43 Correct 87 ms 568 KB Output is correct
44 Correct 118 ms 524 KB Output is correct
45 Correct 163 ms 600 KB Output is correct
46 Correct 264 ms 548 KB Output is correct
47 Correct 298 ms 676 KB Output is correct
48 Correct 64 ms 676 KB Output is correct
49 Correct 55 ms 736 KB Output is correct