QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#291761 | #5522. F*** 3-Colorable Graphs | jzhong0821 | RE | 1ms | 3800kb | C++17 | 1.4kb | 2023-12-27 05:02:05 | 2023-12-27 05:02:05 |
Judging History
answer
#include <iostream>
#include <assert.h>
#include <cstring>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
#define fo(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout)
#define f1(i,k) for(int i=1,end_i=(k);i<=end_i;i++)
#define f0(i,k) for(int i=0,end_i=(k);i< end_i;i++)
#define cle(x) memset(x, 0, sizeof(x))
#define lobit(x) ((x) & -(x))
#define ll long long
#define pb push_back
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define int long long
const int inf = 2e18;
const int lim = 10010;
const int mv = 1500;
int n,m;
int u,v;
vector<int> g[lim];
int a[lim], deg[lim], rk[lim], c[lim];
signed main(){
cin>>n>>m;
f1(i,m){
cin>>u>>v;
g[u].pb(v);
g[v].pb(u);
deg[u]++;
deg[v]++;
}
f1(i,n) a[i] = i;
sort(a+1, a+n+1, [&](int x, int y){return deg[x] < deg[y] || (deg[x] == deg[y] && x < y);});
f1(i,n){
rk[a[i]]=i;
}
int s = 0;
f1(i,n)
{
for(int j:g[i])if(rk[i]>rk[j])for(int k:g[j])if(rk[i]>rk[k])s+=c[k]++;
for(int j:g[i])if(rk[i]>rk[j])for(int k:g[j])c[k]=0;
if(s)break;
}
if(s)cout<<2;
else cout<<3;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3800kb
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: 3736kb
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
Runtime Error
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...