Submission #130385

# Submission time Handle Problem Language Result Execution time Memory
130385 2019-07-15T05:49:53 Z 김세빈(#3148) Information (CEOI08_information) C++14
0 / 100
303 ms 16596 KB
#include <bits/stdc++.h>

using namespace std;

vector <int> G[2020];
vector <int> A, B;
int P[2020], V[2020202];
bool chk[2020];
int n, m;

int find(int p) { return p == P[p]? p : P[p] = find(P[p]); }
void unite(int p, int q) { P[find(p)] = find(q); }

void dfs(int p, int r)
{
	chk[p] = 1;
	
	if(r != -1) A.push_back(r >> 1);
	
	for(int &t: G[p]){
		if((t ^ 1) == r) continue;
		else if(!chk[V[t ^ 1]]){
			dfs(V[t ^ 1], t);
		}
		else if(find(p) != find(V[t ^ 1])){
			unite(p, V[t ^ 1]);
			B.push_back(t >> 1);
		}
	}
}

int main()
{
	int i, u, v;
	
	scanf("%d%d", &n, &m);
	
	for(i=1; i<=n; i++){
		P[i] = i;
	}
	
	for(i=0; i<m+m; i++){
		scanf("%d", V + i);
		G[V[i]].emplace_back(i);
	}
	
	dfs(1, -1);
	
	if(A.size() != n - 1 || B.size() != n - 1){
		printf("None\n");
	}
	else{
		for(int &t: A){
			printf("%d ", t + 1);
		}
		
		printf("\n");
		
		for(int &t: B){
			printf("%d ", t + 1);
		}
		
		printf("\n");
	}
	
	return 0;
}

Compilation message

information.cpp: In function 'int main()':
information.cpp:49:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(A.size() != n - 1 || B.size() != n - 1){
     ~~~~~~~~~^~~~~~~~
information.cpp:49:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(A.size() != n - 1 || B.size() != n - 1){
                          ~~~~~~~~~^~~~~~~~
information.cpp:34:9: warning: unused variable 'u' [-Wunused-variable]
  int i, u, v;
         ^
information.cpp:34:12: warning: unused variable 'v' [-Wunused-variable]
  int i, u, v;
            ^
information.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
information.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", V + i);
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB agent 3 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB agent 5 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB agent 3 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 652 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 2320 KB agent 3 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 3860 KB agent 2 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 2424 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 632 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 504 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 287 ms 16392 KB agent 3 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 275 ms 15784 KB agent 318 did not recieve part 2 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 303 ms 16596 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -