답안 #858712

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
858712 2023-10-09T05:09:35 Z maks007 Joker (BOI20_joker) C++14
0 / 100
2000 ms 12052 KB
#include "bits/stdc++.h"
 
using namespace std;
 
vector <vector <int> > g;
vector <int> used;
int f;
 
void dfs(int v, int dist = 1, int p = -1) {
	used[v] = 1;
	for(auto i : g[v]) {
		if(p == i) continue;
		if(!used[i]) dfs(i, dist+1, v);
		else {
			if((used[v] - used[i] + 1)%2==1) {
				// cout << v << " " << i << "\n";
				f = 1;
			}
		}
	}
}
 
signed main () {
	int n, m, q;
	cin >> n >> m >> q;
	g.resize(n);
	used.resize(n);
	vector <pair <int,int>> edge;
	for(int i = 0; i < m; i ++) {
		int u, v;
		cin >> u >> v;
		edge.push_back({u-1, v-1});
	}
	while(q --) {
		int l, r;
		cin >> l >> r;
		l --, r --;
		for(auto &i : g) i.clear();
		for(auto &i : used) i = 0;
		for(int i = 0; i < l; i ++) {
			g[edge[i].first].push_back(edge[i].second);
			g[edge[i].second].push_back(edge[i].first);
		}
		for(int i = r+1; i < m; i ++) {
			g[edge[i].first].push_back(edge[i].second);
			g[edge[i].second].push_back(edge[i].first);
		}
		for(int i = 0; i < n; i ++) {
			if(!used[i]) {
				f = 0;
				dfs(i);
				if(f) {
					cout << "YES\n";
					goto end;
				}
			}
		}
		cout << "NO\n";
		end:;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 2024 ms 12052 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -