Submission #781232

# Submission time Handle Problem Language Result Execution time Memory
781232 2023-07-13T00:23:52 Z bane Stations (IOI20_stations) C++17
100 / 100
857 ms 708 KB
    #include "stations.h"
    #include<bits/stdc++.h>
     
    using namespace std;
     
    const int Nax = 1005;
     
    class Undirected_Graph{
    	public:
    		
    		int N, Timer = 0;
    		vector<vector<int>>adj;
    		vector<int>in;
     
    		Undirected_Graph(int _N):N(_N){
    			adj.resize(N);
    			in.resize(N);
    		}
     
    		inline void Add_Edge(int A, int B){
    			adj[A].push_back(B);
    			adj[B].push_back(A);
    		}
     
    		void Depth_First_Search(int Node, int Parent, int even = 1){
    			if(even)in[Node] = Timer++;
    			for (int& Next : adj[Node]){
    				if (Next == Parent)continue;
    				Depth_First_Search(Next,Node,even^1);
    			}
					if (!even)in[Node] = Timer++;
    		}
     
    };
     
     
    std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    	std::vector<int> labels(n);
    	Undirected_Graph G(n);
     
    	for (int i = 0; i < n - 1; i++){
    		G.Add_Edge(u[i],v[i]);
    	}
     
    	G.Depth_First_Search(0,0);
     
    	labels = G.in;
     
    	return labels;
    }
     
    int find_next_station(int s, int t, std::vector<int> c) {

			if (c.back() < s){
				//S is out
				for (int i = c.size() - 1 ; i >=0; i--){
					if (t >= c[i] && s >= t)return c[i];
				}
				//parent is lowest even
				return c[0];
			}else{
				// S is in
				for (int i = 0; i + 1 < (int)c.size(); i++){
					if (t >= s&& t <= c[i])return c[i];
				}

				return c.back();
			}
    }
# Verdict Execution time Memory Grader output
1 Correct 426 ms 620 KB Output is correct
2 Correct 394 ms 508 KB Output is correct
3 Correct 694 ms 480 KB Output is correct
4 Correct 565 ms 504 KB Output is correct
5 Correct 416 ms 504 KB Output is correct
6 Correct 326 ms 508 KB Output is correct
7 Correct 398 ms 548 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 1 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 276 ms 496 KB Output is correct
2 Correct 446 ms 612 KB Output is correct
3 Correct 649 ms 416 KB Output is correct
4 Correct 565 ms 420 KB Output is correct
5 Correct 474 ms 420 KB Output is correct
6 Correct 358 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 396 ms 500 KB Output is correct
2 Correct 259 ms 548 KB Output is correct
3 Correct 857 ms 508 KB Output is correct
4 Correct 582 ms 420 KB Output is correct
5 Correct 446 ms 544 KB Output is correct
6 Correct 337 ms 504 KB Output is correct
7 Correct 370 ms 544 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 500 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 442 ms 504 KB Output is correct
12 Correct 391 ms 588 KB Output is correct
13 Correct 347 ms 544 KB Output is correct
14 Correct 369 ms 636 KB Output is correct
15 Correct 40 ms 492 KB Output is correct
16 Correct 48 ms 600 KB Output is correct
17 Correct 93 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 741 ms 416 KB Output is correct
2 Correct 562 ms 504 KB Output is correct
3 Correct 375 ms 420 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 0 ms 500 KB Output is correct
7 Correct 519 ms 504 KB Output is correct
8 Correct 598 ms 512 KB Output is correct
9 Correct 555 ms 416 KB Output is correct
10 Correct 407 ms 508 KB Output is correct
11 Correct 4 ms 492 KB Output is correct
12 Correct 4 ms 500 KB Output is correct
13 Correct 3 ms 500 KB Output is correct
14 Correct 3 ms 496 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 427 ms 512 KB Output is correct
17 Correct 361 ms 504 KB Output is correct
18 Correct 451 ms 504 KB Output is correct
19 Correct 369 ms 504 KB Output is correct
20 Correct 375 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 404 ms 544 KB Output is correct
2 Correct 348 ms 544 KB Output is correct
3 Correct 743 ms 508 KB Output is correct
4 Correct 488 ms 416 KB Output is correct
5 Correct 506 ms 504 KB Output is correct
6 Correct 324 ms 508 KB Output is correct
7 Correct 321 ms 548 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 311 ms 548 KB Output is correct
12 Correct 452 ms 508 KB Output is correct
13 Correct 611 ms 504 KB Output is correct
14 Correct 392 ms 504 KB Output is correct
15 Correct 424 ms 416 KB Output is correct
16 Correct 360 ms 548 KB Output is correct
17 Correct 468 ms 416 KB Output is correct
18 Correct 420 ms 708 KB Output is correct
19 Correct 394 ms 668 KB Output is correct
20 Correct 408 ms 544 KB Output is correct
21 Correct 34 ms 492 KB Output is correct
22 Correct 52 ms 620 KB Output is correct
23 Correct 84 ms 572 KB Output is correct
24 Correct 5 ms 504 KB Output is correct
25 Correct 4 ms 500 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 3 ms 500 KB Output is correct
28 Correct 0 ms 492 KB Output is correct
29 Correct 379 ms 508 KB Output is correct
30 Correct 398 ms 504 KB Output is correct
31 Correct 431 ms 508 KB Output is correct
32 Correct 499 ms 420 KB Output is correct
33 Correct 361 ms 416 KB Output is correct
34 Correct 203 ms 544 KB Output is correct
35 Correct 338 ms 592 KB Output is correct
36 Correct 354 ms 688 KB Output is correct
37 Correct 430 ms 576 KB Output is correct
38 Correct 416 ms 580 KB Output is correct
39 Correct 445 ms 632 KB Output is correct
40 Correct 377 ms 640 KB Output is correct
41 Correct 380 ms 588 KB Output is correct
42 Correct 45 ms 620 KB Output is correct
43 Correct 87 ms 572 KB Output is correct
44 Correct 118 ms 544 KB Output is correct
45 Correct 149 ms 504 KB Output is correct
46 Correct 268 ms 544 KB Output is correct
47 Correct 229 ms 544 KB Output is correct
48 Correct 54 ms 612 KB Output is correct
49 Correct 51 ms 688 KB Output is correct