Submission #130419

# Submission time Handle Problem Language Result Execution time Memory
130419 2019-07-15T07:36:46 Z 이온조(#3149) Information (CEOI08_information) C++14
41 / 100
236 ms 20612 KB
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int N, M;
vector<pii> adj[2009], R[2009];
bool v1[2009], v2[2009];
int h[1000009];

void dfs(int x) {
	v1[x] = 1;
	for(auto& it: adj[x]) {
		if(!v1[it.first]) {
			h[it.second] = 1;
			dfs(it.first);
		}
	}
}

void go(int x) {
	v2[x] = 1;
	for(auto& it: adj[x]) {
		int t, i; tie(t, i) = it;
		if(!v2[t]) {
			if(h[i] == 0) {
				h[i] = 2;
				go(t);
			}
			else if(h[i] == 1 && R[t].size()) {
				int rt, ri; tie(rt, ri) = R[t].back(); R[t].pop_back();
				h[i] = 2; h[ri] = 1;
				go(t);
			}
		}
	}
}

int main() {
	scanf("%d%d",&N,&M);
	for(int i=1; i<=M; i++) {
		int u, v; scanf("%d%d",&u,&v);
		adj[u].push_back({v, i});
	}
	dfs(1);
	for(int i=1; i<=N; i++) {
		for(auto& it: adj[i]) {
			if(!h[it.second]) R[it.first].push_back({i, it.second});
		}
	}
	go(1);
	vector<int> A1, A2;
	for(int i=1; i<=N; i++) for(auto& it: adj[i]) {
		if(h[it.second] == 1) A1.push_back(it.second);
		if(h[it.second] == 2) A2.push_back(it.second);
	}
	if((int)A1.size() != N-1 || (int)A2.size() != N-1) puts("NONE");
	else {
		for(auto& it: A1) printf("%d ",it); puts("");
		for(auto& it: A2) printf("%d ",it);
	}
	return 0;
}

Compilation message

information.cpp: In function 'int main()':
information.cpp:58:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   for(auto& it: A1) printf("%d ",it); puts("");
   ^~~
information.cpp:58:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   for(auto& it: A1) printf("%d ",it); puts("");
                                       ^~~~
information.cpp:39: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:41:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int u, v; scanf("%d%d",&u,&v);
             ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB agent 5 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB agent 2 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB agent 7 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB agent 2 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 632 KB agent 2 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB agent 12 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB agent 21 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB agent 8 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 3192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 4844 KB agent 2 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 3320 KB agent 6 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 632 KB agent 9 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Correct 232 ms 20412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 221 ms 20004 KB agent 318 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 236 ms 20612 KB agent 2 did not recieve part 1 of the message
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 632 KB agent 6 did not recieve part 1 of the message
2 Halted 0 ms 0 KB -