Submission #1057796

# Submission time Handle Problem Language Result Execution time Memory
1057796 2024-08-14T06:13:49 Z 김은성(#11075) Infiltration (CCO24_day2problem1) C++17
0 / 25
10 ms 1116 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);
	if(n != 100)
		return 0;
	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:48:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |   scanf("%d %d", &u, &v);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1116 KB Node sequence is invalid
2 Halted 0 ms 0 KB -