QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#155885#5522. F*** 3-Colorable Graphsdanielkou5855ML 1ms3416kbC++17757b2023-09-02 12:02:062023-09-02 12:02:07

Judging History

你现在查看的是最新测评结果

  • [2023-09-02 12:02:07]
  • 评测
  • 测评结果:ML
  • 用时:1ms
  • 内存:3416kb
  • [2023-09-02 12:02:06]
  • 提交

answer

// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	cin.tie(0) -> sync_with_stdio(0);

	int N, M; cin >> N >> M;

	vector<vector<int>> adj(2 * N);

	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b; a--; b--;

		adj[a].push_back(b); adj[b].push_back(a);
	}

	bool visited[2 * N][2 * N];

	for (int i = 0; i < 2 * N; i++) {
		for (int j = 0; j < 2 * N; j++) {
			visited[i][j] = false;
		}
	}

	for (int i = 0; i < 2 * N; i++) {
		for (auto j : adj[i]) {
			for (auto k : adj[i]) {
				if (j == k) {
					continue;
				}

				if (visited[j][k]) {
					cout << 2 << "\n";
					return 0;
				}

				visited[j][k] = true;
			}
		}
	}

	cout << 3 << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3416kb

input:

2 4
1 3
1 4
2 3
2 4

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3356kb

input:

3 5
1 4
2 4
2 5
3 5
3 6

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: -100
Memory Limit Exceeded

input:

10000 20000
4570 11730
8803 16440
4257 15381
4455 17636
5256 13543
2172 18421
7735 17847
8537 16010
6175 12263
1079 13410
335 15901
3272 16233
7435 11454
4469 13374
1564 13416
1264 13446
7484 14510
8193 12267
628 15585
1388 11398
5444 19958
2059 18140
8947 13188
6214 17707
7940 12253
6726 11508
1839...

output:


result: