답안 #1057803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1057803 2024-08-14T06:16:26 Z 김은성(#11075) Infiltration (CCO24_day2problem1) C++17
3 / 25
20 ms 1228 KB
#define TEST 1200
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[109];
vector<int> routea[109], routeb[109];
bool ch[109];
void dfs(int r, int v){
	ch[v] = 1;
	routea[r].push_back(v);
	for(int u: graph[v]){
		if(!ch[u]){
			dfs(r, u);
			routea[r].push_back(v);
		}
	}
}
void printanswer(int n){
	printf("%d\n", TEST);
	int i, j;
	for(j=0; j<n; j++){
		for(i=1; i<=TEST; i++){
			int temp = (i+1)/2;
			if(temp >= routea[j].size())
				printf("%d ", routea[j].empty() ? j : routea[j].back());
			else
				printf("%d ", routea[j][temp]);
		}
		printf("\n");
	}
	
	for(j=0; j<n; j++){
		for(i=1; i<=TEST; i++){
			int temp = (i+2)/2;
			if(temp >= routeb[j].size())
				printf("%d ", routeb[j].empty() ? j : routeb[j].back());
			else
				printf("%d ", routeb[j][temp]);
		}
		printf("\n");
	}
}
int main(){
	int n, u, v, i;
	scanf("%d", &n);
	for(i=1; i<n; i++){
		scanf("%d %d", &u, &v);
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	for(i=0; i<n; i++){
		memset(ch, 0, sizeof(ch));
		dfs(i, i);
	}
	printanswer(n);
	return 0;
}

Compilation message

Main.cpp: In function 'void printanswer(int)':
Main.cpp:23:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |    if(temp >= routea[j].size())
      |       ~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:34:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |    if(temp >= routeb[j].size())
      |       ~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
Main.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |   scanf("%d %d", &u, &v);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 14 ms 1116 KB Partially correct
2 Partially correct 10 ms 1112 KB Partially correct
3 Partially correct 17 ms 1116 KB Partially correct
4 Partially correct 12 ms 1116 KB Partially correct
5 Partially correct 11 ms 1192 KB Partially correct
6 Partially correct 11 ms 1116 KB Partially correct
7 Partially correct 19 ms 1068 KB Partially correct
8 Partially correct 12 ms 1112 KB Partially correct
9 Partially correct 11 ms 1092 KB Partially correct
10 Partially correct 19 ms 1032 KB Partially correct
11 Partially correct 10 ms 1116 KB Partially correct
12 Partially correct 10 ms 1116 KB Partially correct
13 Partially correct 12 ms 1060 KB Partially correct
14 Partially correct 12 ms 1116 KB Partially correct
15 Partially correct 10 ms 1196 KB Partially correct
16 Partially correct 12 ms 1172 KB Partially correct
17 Partially correct 10 ms 1116 KB Partially correct
18 Partially correct 20 ms 1228 KB Partially correct
19 Partially correct 20 ms 1212 KB Partially correct
20 Partially correct 10 ms 1112 KB Partially correct
21 Partially correct 14 ms 1116 KB Partially correct
22 Partially correct 13 ms 1112 KB Partially correct
23 Partially correct 11 ms 1116 KB Partially correct
24 Partially correct 10 ms 1116 KB Partially correct
25 Partially correct 10 ms 1116 KB Partially correct