답안 #416990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
416990 2021-06-03T09:50:52 Z aryan12 Joker (BOI20_joker) C++17
14 / 100
2000 ms 20348 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200005;
vector<int> g[N];
int color[N];

bool dfs(int node, int col) {
	color[node] = col;
	for(int i = 0; i < g[node].size(); i++) {
		if(color[g[node][i]] == -1) {
			if(dfs(g[node][i], 1 - col))
				return true;
		}
		else if(color[g[node][i]] == color[node])
			return true;
	}
	return false;
}

bool isBipartite(int n) {
	for(int i = 1; i <= n; i++) {
		if(color[i] == -1) {
			if(dfs(i, 0))
				return true;
		}
	}
	return false;
}

void Solve() {
	int n, m, q;
	cin >> n >> m >> q;
	vector<pair<int, int> > edges;
	for(int i = 1; i <= m; i++) {
		int u, v;
		cin >> u >> v;
		edges.push_back(make_pair(u, v));
	}
	for(int i = 1; i <= q; i++) {
		for(int i = 0; i <= n; i++) {
			color[i] = -1;
			g[i].clear();
		}
		int left, right;
		cin >> left >> right;
		left--, right--;
		for(int i = 0; i < left; i++) {
			g[edges[i].first].push_back(edges[i].second);
			g[edges[i].second].push_back(edges[i].first);
		}
		for(int i = right + 1; i < m; i++) {
			g[edges[i].first].push_back(edges[i].second);
			g[edges[i].second].push_back(edges[i].first);	
		}
		if(isBipartite(n)) {
			cout << "YES\n";
		}
		else {
			cout << "NO\n";
		}
	}
}

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	while(t--) {
		Solve();
	}
	return 0;
}

Compilation message

Joker.cpp: In function 'bool dfs(long long int, long long int)':
Joker.cpp:13:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i = 0; i < g[node].size(); i++) {
      |                 ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4912 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 5016 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 5 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
9 Correct 5 ms 4932 KB Output is correct
10 Correct 4 ms 4940 KB Output is correct
11 Correct 4 ms 4940 KB Output is correct
12 Correct 4 ms 4940 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 4 ms 4940 KB Output is correct
15 Correct 4 ms 4940 KB Output is correct
16 Correct 4 ms 5020 KB Output is correct
17 Correct 4 ms 4940 KB Output is correct
18 Correct 4 ms 5016 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 4 ms 5012 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 4 ms 4940 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 4 ms 5020 KB Output is correct
26 Correct 4 ms 4940 KB Output is correct
27 Correct 4 ms 5008 KB Output is correct
28 Correct 4 ms 4940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4912 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 5016 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 5 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
9 Correct 5 ms 4932 KB Output is correct
10 Correct 4 ms 4940 KB Output is correct
11 Correct 4 ms 4940 KB Output is correct
12 Correct 4 ms 4940 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 4 ms 4940 KB Output is correct
15 Correct 4 ms 4940 KB Output is correct
16 Correct 4 ms 5020 KB Output is correct
17 Correct 4 ms 4940 KB Output is correct
18 Correct 4 ms 5016 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 4 ms 5012 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 4 ms 4940 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 4 ms 5020 KB Output is correct
26 Correct 4 ms 4940 KB Output is correct
27 Correct 4 ms 5008 KB Output is correct
28 Correct 4 ms 4940 KB Output is correct
29 Correct 113 ms 5108 KB Output is correct
30 Correct 106 ms 5068 KB Output is correct
31 Correct 91 ms 5172 KB Output is correct
32 Correct 66 ms 5156 KB Output is correct
33 Correct 51 ms 5144 KB Output is correct
34 Correct 96 ms 5176 KB Output is correct
35 Correct 115 ms 5172 KB Output is correct
36 Correct 63 ms 5188 KB Output is correct
37 Correct 149 ms 5188 KB Output is correct
38 Correct 149 ms 5172 KB Output is correct
39 Correct 93 ms 5168 KB Output is correct
40 Correct 62 ms 5172 KB Output is correct
41 Correct 61 ms 5164 KB Output is correct
42 Correct 61 ms 5160 KB Output is correct
43 Correct 75 ms 5068 KB Output is correct
44 Correct 81 ms 5224 KB Output is correct
45 Correct 92 ms 5164 KB Output is correct
46 Correct 97 ms 5068 KB Output is correct
47 Correct 63 ms 5148 KB Output is correct
48 Correct 68 ms 5148 KB Output is correct
49 Correct 82 ms 5144 KB Output is correct
50 Correct 99 ms 5280 KB Output is correct
51 Correct 64 ms 5152 KB Output is correct
52 Correct 72 ms 5068 KB Output is correct
53 Correct 89 ms 5164 KB Output is correct
54 Correct 113 ms 5164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4912 KB Output is correct
3 Execution timed out 2043 ms 19384 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4912 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 5016 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 5 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
9 Correct 5 ms 4932 KB Output is correct
10 Correct 4 ms 4940 KB Output is correct
11 Correct 4 ms 4940 KB Output is correct
12 Correct 4 ms 4940 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 4 ms 4940 KB Output is correct
15 Correct 4 ms 4940 KB Output is correct
16 Correct 4 ms 5020 KB Output is correct
17 Correct 4 ms 4940 KB Output is correct
18 Correct 4 ms 5016 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 4 ms 5012 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 4 ms 4940 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 4 ms 5020 KB Output is correct
26 Correct 4 ms 4940 KB Output is correct
27 Correct 4 ms 5008 KB Output is correct
28 Correct 4 ms 4940 KB Output is correct
29 Execution timed out 2043 ms 19384 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4912 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 5016 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 5 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
9 Correct 5 ms 4932 KB Output is correct
10 Correct 4 ms 4940 KB Output is correct
11 Correct 4 ms 4940 KB Output is correct
12 Correct 4 ms 4940 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 4 ms 4940 KB Output is correct
15 Correct 4 ms 4940 KB Output is correct
16 Correct 4 ms 5020 KB Output is correct
17 Correct 4 ms 4940 KB Output is correct
18 Correct 4 ms 5016 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 4 ms 5012 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 4 ms 4940 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 4 ms 5020 KB Output is correct
26 Correct 4 ms 4940 KB Output is correct
27 Correct 4 ms 5008 KB Output is correct
28 Correct 4 ms 4940 KB Output is correct
29 Correct 113 ms 5108 KB Output is correct
30 Correct 106 ms 5068 KB Output is correct
31 Correct 91 ms 5172 KB Output is correct
32 Correct 66 ms 5156 KB Output is correct
33 Correct 51 ms 5144 KB Output is correct
34 Correct 96 ms 5176 KB Output is correct
35 Correct 115 ms 5172 KB Output is correct
36 Correct 63 ms 5188 KB Output is correct
37 Correct 149 ms 5188 KB Output is correct
38 Correct 149 ms 5172 KB Output is correct
39 Correct 93 ms 5168 KB Output is correct
40 Correct 62 ms 5172 KB Output is correct
41 Correct 61 ms 5164 KB Output is correct
42 Correct 61 ms 5160 KB Output is correct
43 Correct 75 ms 5068 KB Output is correct
44 Correct 81 ms 5224 KB Output is correct
45 Correct 92 ms 5164 KB Output is correct
46 Correct 97 ms 5068 KB Output is correct
47 Correct 63 ms 5148 KB Output is correct
48 Correct 68 ms 5148 KB Output is correct
49 Correct 82 ms 5144 KB Output is correct
50 Correct 99 ms 5280 KB Output is correct
51 Correct 64 ms 5152 KB Output is correct
52 Correct 72 ms 5068 KB Output is correct
53 Correct 89 ms 5164 KB Output is correct
54 Correct 113 ms 5164 KB Output is correct
55 Execution timed out 2074 ms 20348 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4912 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 5016 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 5 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
9 Correct 5 ms 4932 KB Output is correct
10 Correct 4 ms 4940 KB Output is correct
11 Correct 4 ms 4940 KB Output is correct
12 Correct 4 ms 4940 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 4 ms 4940 KB Output is correct
15 Correct 4 ms 4940 KB Output is correct
16 Correct 4 ms 5020 KB Output is correct
17 Correct 4 ms 4940 KB Output is correct
18 Correct 4 ms 5016 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 4 ms 5012 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 4 ms 4940 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 4 ms 5020 KB Output is correct
26 Correct 4 ms 4940 KB Output is correct
27 Correct 4 ms 5008 KB Output is correct
28 Correct 4 ms 4940 KB Output is correct
29 Correct 113 ms 5108 KB Output is correct
30 Correct 106 ms 5068 KB Output is correct
31 Correct 91 ms 5172 KB Output is correct
32 Correct 66 ms 5156 KB Output is correct
33 Correct 51 ms 5144 KB Output is correct
34 Correct 96 ms 5176 KB Output is correct
35 Correct 115 ms 5172 KB Output is correct
36 Correct 63 ms 5188 KB Output is correct
37 Correct 149 ms 5188 KB Output is correct
38 Correct 149 ms 5172 KB Output is correct
39 Correct 93 ms 5168 KB Output is correct
40 Correct 62 ms 5172 KB Output is correct
41 Correct 61 ms 5164 KB Output is correct
42 Correct 61 ms 5160 KB Output is correct
43 Correct 75 ms 5068 KB Output is correct
44 Correct 81 ms 5224 KB Output is correct
45 Correct 92 ms 5164 KB Output is correct
46 Correct 97 ms 5068 KB Output is correct
47 Correct 63 ms 5148 KB Output is correct
48 Correct 68 ms 5148 KB Output is correct
49 Correct 82 ms 5144 KB Output is correct
50 Correct 99 ms 5280 KB Output is correct
51 Correct 64 ms 5152 KB Output is correct
52 Correct 72 ms 5068 KB Output is correct
53 Correct 89 ms 5164 KB Output is correct
54 Correct 113 ms 5164 KB Output is correct
55 Execution timed out 2043 ms 19384 KB Time limit exceeded
56 Halted 0 ms 0 KB -