Submission #130388

# Submission time Handle Problem Language Result Execution time Memory
130388 2019-07-15T05:58:51 Z 김세빈(#3148) Information (CEOI08_information) C++14
0 / 100
301 ms 16368 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, x;

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 3 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 4 ms 632 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 508 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 372 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 2296 KB agent 3 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 3836 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 632 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 289 ms 16368 KB agent 3 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 274 ms 15800 KB agent 318 did not recieve part 2 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 301 ms 16304 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -