QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#99376 | #5522. F*** 3-Colorable Graphs | UCSC_Ravioli | TL | 2ms | 3444kb | C++20 | 971b | 2023-04-22 03:14:07 | 2023-04-22 03:14:08 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
int main(){
ios::sync_with_stdio(false); cin.tie(0);
int n, m;
cin >> n >> m;
n *= 2;
vector<unordered_set<int>> adj(n+1);
vector<array<int,2>> edges(m);
for(int i=0; i<m; i++){
int a, b;
cin >> a >> b;
adj[a].insert(b);
adj[b].insert(a);
edges[i] = {a,b};
}
bool found=0;
for(int u=1; u<=n && !found; u++){
for(int v=1; v<=n && !found; v++){
if(u==v) continue;
bool ok = 0;
if(adj[u].size() < adj[v].size()){
for(int x : adj[u]){
if(adj[v].count(x)){
if(ok) found = 1;
ok = true;
}
}
}
else{
for(int x : adj[v]){
if(adj[u].count(x)){
if(ok) found = 1;
ok = true;
}
}
}
}
}
cout << (found ? 2 : 3);
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3300kb
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: 2ms
memory: 3444kb
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
Time 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...