답안 #590113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
590113 2022-07-05T14:27:26 Z almothana05 기지국 (IOI20_stations) C++14
100 / 100
942 ms 928 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
vector<int> gr[2000] , num , de ;
int  vis[2000];
int pl = -1;
void dfs(int x , int cmp){
	de.push_back(x);
	vis[x] = 1;
	// cout << x << ' ' << cmp << "\n";
	if(cmp == 0){
	pl++;
		num[x] = pl;
	}
		// cout << 1 << ' ';
	for(int i = 0 ; i< gr[x].size() ; i++){
		int kind = gr[x][i];
		if(vis[kind] == 0){
			dfs(kind , cmp ^ 1);
		}
	}
	// assert(pl > 0);
	
	if(cmp == 1){
	pl++;
		num[x] = pl;
	}
	while(num[x] == -1);
}
vector<int> label(int menge, int maxi, vector<int> u, vector<int> v) {
	num.clear();
	de.clear();
	for(int i = 0 ; i < 1000 ; i++){
		gr[i].clear();
		vis[i] = 0;
	}
	pl = -1;
	num.resize(menge , -1);
	for(int i = 0 ; i < menge - 1 ; i++){
		gr[u[i]].push_back(v[i]);
		gr[v[i]].push_back(u[i]);
	}
	for(int i = 0 ; i < menge ; i++){
		if(vis[i] == 0){
			dfs(i , 0);
		}
		// while(num[i] == -1);
	}
	assert(de.size() == menge);
	for(int i = 0 ; i < menge ; i++){
		// cout << num[i] << ' ';
		// assert(num[i] >= 0);
	}
	// cout << "\n";
	return num;
}
 
int find_next_station(int s, int t, vector<int> c) {
	int be , en , erg = -1;
	if(s < c[0]){
		be = s;
		for(int i = 0 ; i < c.size() - 1 ; i++){
			en = c[i];
			if(be <= t && t <= en){
				return c[i];
			}
			be = c[i];
		}
		return c[c.size() - 1];
	}
	else{
		c.push_back(s);
		for(int i = 1 ; i < c.size() - 1 ; i++){
			be = c[i];
			en = c[i + 1] - 1;
			if(be <= t && t <= en){
				return c[i];
			}
		}
		return c[0];
	}
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i = 0 ; i< gr[x].size() ; i++){
      |                  ~^~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from stations.cpp:3:
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:50:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |  assert(de.size() == menge);
      |         ~~~~~~~~~~^~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:63:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   for(int i = 0 ; i < c.size() - 1 ; i++){
      |                   ~~^~~~~~~~~~~~~~
stations.cpp:74:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |   for(int i = 1 ; i < c.size() - 1 ; i++){
      |                   ~~^~~~~~~~~~~~~~
stations.cpp:60:16: warning: unused variable 'erg' [-Wunused-variable]
   60 |  int be , en , erg = -1;
      |                ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 503 ms 928 KB Output is correct
2 Correct 448 ms 792 KB Output is correct
3 Correct 883 ms 676 KB Output is correct
4 Correct 643 ms 672 KB Output is correct
5 Correct 579 ms 676 KB Output is correct
6 Correct 416 ms 792 KB Output is correct
7 Correct 421 ms 688 KB Output is correct
8 Correct 2 ms 748 KB Output is correct
9 Correct 4 ms 756 KB Output is correct
10 Correct 1 ms 756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 442 ms 672 KB Output is correct
2 Correct 508 ms 672 KB Output is correct
3 Correct 692 ms 672 KB Output is correct
4 Correct 578 ms 684 KB Output is correct
5 Correct 598 ms 680 KB Output is correct
6 Correct 428 ms 740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 473 ms 808 KB Output is correct
2 Correct 435 ms 800 KB Output is correct
3 Correct 749 ms 676 KB Output is correct
4 Correct 606 ms 692 KB Output is correct
5 Correct 564 ms 672 KB Output is correct
6 Correct 472 ms 680 KB Output is correct
7 Correct 387 ms 680 KB Output is correct
8 Correct 1 ms 752 KB Output is correct
9 Correct 5 ms 748 KB Output is correct
10 Correct 0 ms 748 KB Output is correct
11 Correct 575 ms 676 KB Output is correct
12 Correct 401 ms 816 KB Output is correct
13 Correct 508 ms 812 KB Output is correct
14 Correct 482 ms 688 KB Output is correct
15 Correct 55 ms 748 KB Output is correct
16 Correct 67 ms 748 KB Output is correct
17 Correct 111 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 942 ms 672 KB Output is correct
2 Correct 702 ms 672 KB Output is correct
3 Correct 642 ms 684 KB Output is correct
4 Correct 2 ms 756 KB Output is correct
5 Correct 6 ms 756 KB Output is correct
6 Correct 0 ms 748 KB Output is correct
7 Correct 582 ms 680 KB Output is correct
8 Correct 929 ms 672 KB Output is correct
9 Correct 707 ms 676 KB Output is correct
10 Correct 591 ms 680 KB Output is correct
11 Correct 9 ms 752 KB Output is correct
12 Correct 5 ms 748 KB Output is correct
13 Correct 4 ms 748 KB Output is correct
14 Correct 4 ms 748 KB Output is correct
15 Correct 1 ms 748 KB Output is correct
16 Correct 483 ms 680 KB Output is correct
17 Correct 528 ms 712 KB Output is correct
18 Correct 563 ms 672 KB Output is correct
19 Correct 504 ms 684 KB Output is correct
20 Correct 419 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 534 ms 800 KB Output is correct
2 Correct 430 ms 812 KB Output is correct
3 Correct 823 ms 672 KB Output is correct
4 Correct 699 ms 680 KB Output is correct
5 Correct 603 ms 672 KB Output is correct
6 Correct 404 ms 812 KB Output is correct
7 Correct 442 ms 680 KB Output is correct
8 Correct 3 ms 748 KB Output is correct
9 Correct 5 ms 756 KB Output is correct
10 Correct 1 ms 760 KB Output is correct
11 Correct 441 ms 756 KB Output is correct
12 Correct 557 ms 688 KB Output is correct
13 Correct 915 ms 672 KB Output is correct
14 Correct 745 ms 688 KB Output is correct
15 Correct 523 ms 672 KB Output is correct
16 Correct 482 ms 688 KB Output is correct
17 Correct 559 ms 684 KB Output is correct
18 Correct 378 ms 688 KB Output is correct
19 Correct 513 ms 784 KB Output is correct
20 Correct 495 ms 676 KB Output is correct
21 Correct 60 ms 616 KB Output is correct
22 Correct 91 ms 792 KB Output is correct
23 Correct 107 ms 676 KB Output is correct
24 Correct 5 ms 748 KB Output is correct
25 Correct 5 ms 752 KB Output is correct
26 Correct 4 ms 748 KB Output is correct
27 Correct 2 ms 700 KB Output is correct
28 Correct 2 ms 748 KB Output is correct
29 Correct 433 ms 688 KB Output is correct
30 Correct 502 ms 672 KB Output is correct
31 Correct 486 ms 684 KB Output is correct
32 Correct 475 ms 676 KB Output is correct
33 Correct 525 ms 684 KB Output is correct
34 Correct 254 ms 800 KB Output is correct
35 Correct 429 ms 792 KB Output is correct
36 Correct 476 ms 816 KB Output is correct
37 Correct 482 ms 820 KB Output is correct
38 Correct 429 ms 812 KB Output is correct
39 Correct 431 ms 804 KB Output is correct
40 Correct 395 ms 700 KB Output is correct
41 Correct 452 ms 800 KB Output is correct
42 Correct 48 ms 676 KB Output is correct
43 Correct 106 ms 672 KB Output is correct
44 Correct 120 ms 676 KB Output is correct
45 Correct 140 ms 788 KB Output is correct
46 Correct 259 ms 676 KB Output is correct
47 Correct 300 ms 684 KB Output is correct
48 Correct 57 ms 800 KB Output is correct
49 Correct 56 ms 844 KB Output is correct