QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#401750 | #6830. Just Some Bad Memory | Hzwei | WA | 59ms | 22148kb | C++20 | 8.5kb | 2024-04-29 11:52:44 | 2024-04-29 11:52:46 |
Judging History
answer
//Crimson flames tied through my ears
//Rollin' high and mighty traps
//Pounced with fire on flaming roads
//Using ideas as my maps
//"We'll meet on edges, soon," said I
//Proud 'neath heated brow
//Ah, but I was so much older then
//I'm younger than that now.
//
//Half-cracked prejudice leaped forth
//"Rip down all hate," I screamed
//Lies that life is black and white
//Spoke from my skull, I dreamed
//Romantic facts of musketeers
//Foundationed deep, somehow
//Ah, but I was so much older then
//I'm younger than that now.
//
//Girls' faces formed the forward path
//From phony jealousy
//To memorizing politics
//Of ancient history
//Flung down by corpse evangelists
//Unthought of, thought, somehow
//Ah, but I was so much older then
//I'm younger than that now.
//A self-ordained professor's tongue
//Too serious to fool
//Spouted out that liberty
//Is just equality in school
//"Equality," I spoke the word
//As if a wedding vow
//Ah, but I was so much older then
//I'm younger than that now.
//
//In a soldier's stance, I aimed my hand
//At the mongrel dogs who teach
//Fearing not that I'd become my enemy
//In the instant that I preach
//My existence led by confusion boats
//Mutiny from stern to bow
//Ah, but I was so much older then
//I'm younger than that now.
//
//Yes, my guard stood hard when abstract threats
//Too noble to neglect
//Deceived me into thinking
//I had something to protect
//Good and bad, I define these terms
//Quite clear, no doubt, somehow
//Ah, but I was so much older then
//I'm younger than that now.
#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
/*=====================================================================*/
#define ll long long
//#define int ll
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pdd pair<double,double>
#define ull unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(s) (s).begin(),(s).end()
#define repd(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define forr(i,a,b,c) for(int i=(int)(a);i<=(int)(b);i+=(int)(c))
#define forn(i,p,n) for(int i=(int)(p);i<=(int)(n);++i)
#define ford(i,p,n) for(int i=(int)(n);i>=(int)(p);--i)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define modcg(x) if(x>=mod)x-=mod;
#define modcl(x) if(x<0)x+=mod;
#define lowbit(x) ((x)&(-(x)))
#define ckmax(x,y) x=max(x,y)
#define ckmin(x,y) x=min(x,y)
/*=====================================================================*/
mt19937 GeN(chrono::system_clock::now().time_since_epoch().count());
int Rand(int l,int r)
{
uniform_int_distribution<>RAND1(l,r);
return RAND1(GeN);
}
struct Fastmod
{
int mod,b;
typedef __int128 lll;
void init(int m)
{
mod=m;
b=((lll)1<<64)/mod;
}
int operator()(ull a)
{
int q=((lll)a*b)>>64,r=a-q*mod;
modcg(r);
return r;
}
}MOD;
int mul(int a,int b)
{
return MOD(a*b);
}
/*======================================================================*/
//think twice,code once
//think once,debug forever
const int MAXN=1e5+10;
vi v[MAXN];
int n,m;
namespace SUB5
{
bool check5()
{
return m==0;
}
};
namespace SUB4
{
bool check4()
{
return m==1;
}
};
namespace SUB0
{
bool f0=0,f1=0;
int use[MAXN],col[MAXN],cnt[2][MAXN],vis[MAXN],ins[MAXN],f[MAXN];
void dfs(int now,int fa)
{
// if(fa)
// {
// cout<<now<<" "<<fa<<endl;
// }
use[now]=1;ins[now]=1;
for(int u:v[now])
{
if(u==fa)
{
continue;
}
if(!use[u])
{
col[u]=col[now]^1;
f[u]=now;
dfs(u,now);
}
else
{
if(ins[u])
{
cnt[col[now]][now]++;cnt[col[now]][u]--;
}
if(col[u]==col[now])
{
f0=1;
}
else
{
f1=1;
}
}
}
ins[now]=0;
}
void dfs1(int now,int fa)
{
vis[now]=1;
for(int u:v[now])
{
if(u==fa)
{
continue;
}
if(!vis[u])
{
dfs1(u,now);
cnt[0][now]+=cnt[0][u];
cnt[1][now]+=cnt[1][u];
}
}
}
bool check0()
{
forn(i,1,n)
{
if(!use[i])
{
dfs(i,0);
dfs1(i,0);
}
}
if(f0&&f1)
{
return 1;
}
if(f0)
{
forn(i,1,n)
{
// if(cnt[i])
// {
// cout<<i<<" "<<cnt[i]<<endl;
// }
if(cnt[0][i]&&cnt[1][i])
{
return 1;
}
}
}
if(f1)
{
forn(i,1,n)
{
// if(cnt[i])
// {
// cout<<i<<" "<<cnt[i]<<endl;
// }
if(cnt[0][i]>=2||cnt[1][i]>=2)
{
return 1;
}
}
}
return 0;
}
};
namespace SUB1
{
bool f0=0,f1=0;
int use[MAXN],col[MAXN];
vi s[2];
void dfs(int now,int fa)
{
s[col[now]].pb(now);
use[now]=1;
for(int u:v[now])
{
if(u==fa)
{
continue;
}
if(!use[u])
{
col[u]=col[now]^1;
dfs(u,now);
}
else
{
if(col[u]==col[now])
{
f0=1;
}
else
{
f1=1;
}
}
}
}
bool g0=0,g1=0;
bool check1()
{
forn(i,1,n)
{
if(!use[i])
{
s[0].clear();s[1].clear();
dfs(i,0);
if(!g0)
{
for(int u:s[0])
{
int cnt=0;
for(int x:v[u])
{
cnt+=col[x]==0;
}
if(cnt!=s[0].size()-1)
{
g0=1;
break;
}
}
for(int u:s[1])
{
int cnt=0;
for(int x:v[u])
{
cnt+=col[x]==1;
}
if(cnt!=s[1].size()-1)
{
g0=1;
break;
}
}
}
if(!g1)
{
for(int u:s[0])
{
int cnt=0;
for(int x:v[u])
{
cnt+=col[x]==1;
}
if(cnt!=s[1].size())
{
g1=1;
break;
}
}
for(int u:s[1])
{
int cnt=0;
for(int x:v[u])
{
cnt+=col[x]==0;
}
if(cnt!=s[0].size())
{
g1=1;
break;
}
}
}
}
}
if(f0&&g1)
{
return 1;
}
if(f1&&g0)
{
return 1;
}
return 0;
}
};
namespace SUB2
{
bool f0=0,f1=0;
int use[MAXN],col[MAXN];
vi s[2];
void dfs(int now,int fa)
{
s[col[now]].pb(now);
use[now]=1;
for(int u:v[now])
{
if(u==fa)
{
continue;
}
if(!use[u])
{
col[u]=col[now]^1;
dfs(u,now);
}
else
{
if(col[u]==col[now])
{
f0=1;
}
else
{
f1=1;
}
}
}
}
bool g0=0,g1=0;
bool check2()
{
forn(i,1,n)
{
if(!use[i])
{
s[0].clear();s[1].clear();
dfs(i,0);
if(!g0)
{
for(int u:s[0])
{
int cnt=0;
for(int x:v[u])
{
cnt+=col[x]==0;
}
if(cnt!=s[0].size()-1)
{
g0=1;
break;
}
}
for(int u:s[1])
{
int cnt=0;
for(int x:v[u])
{
cnt+=col[x]==1;
}
if(cnt!=s[1].size()-1)
{
g0=1;
break;
}
}
}
if(!g1)
{
for(int u:s[0])
{
int cnt=0;
for(int x:v[u])
{
cnt+=col[x]==1;
}
if(cnt!=s[1].size())
{
g1=1;
break;
}
}
for(int u:s[1])
{
int cnt=0;
for(int x:v[u])
{
cnt+=col[x]==0;
}
if(cnt!=s[0].size())
{
g1=1;
break;
}
}
}
}
}
if(f0||f1)
{
return 1;
}
if(g0&&g1)
{
return 1;
}
return 0;
}
};
void solve()
{
cin>>n>>m;
forn(i,1,m)
{
int x,y;
cin>>x>>y;
v[x].pb(y);
v[y].pb(x);
}
if(n<=3)
{
cout<<-1<<endl;
return;
}
if(SUB5::check5())
{
cout<<5<<endl;
return;
}
if(SUB4::check4())
{
cout<<4<<endl;
return;
}
if(SUB0::check0())
{
cout<<0<<endl;
return;
}
if(SUB1::check1())
{
cout<<1<<endl;
return;
}
if(SUB2::check2())
{
cout<<2<<endl;
return;
}
cout<<3<<endl;
}
/*======================================================================*/
signed main()
{
cin.tie(0);
cout.tie(0);
std::ios::sync_with_stdio(false);
//#define Hank2007
#ifdef Hank2007
freopen("input.txt","r",stdin);
freopen("output1.txt","w",stdout);
#endif
/*====================================================================*/
int TEST_CASE=1;
// cin>>TEST_CASE;
while(TEST_CASE--)
{
solve();
}
return 0;
}
/*
//
start coding at
finish debugging at
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3684kb
input:
3 3 1 2 2 3 1 3
output:
-1
result:
ok "-1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
4 0
output:
5
result:
ok "5"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
5 4 1 2 2 3 3 4 4 5
output:
2
result:
ok "2"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
4 6 1 2 1 3 1 4 2 3 2 4 3 4
output:
0
result:
ok "0"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
4 4 1 2 2 3 3 4 4 1
output:
1
result:
ok "1"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
7 7 1 2 2 3 3 4 4 1 5 6 6 7 7 5
output:
0
result:
ok "0"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
4 3 1 2 2 3 3 1
output:
2
result:
ok "2"
Test #8:
score: 0
Accepted
time: 32ms
memory: 14240kb
input:
100000 99999 13413 22698 22698 36667 13413 64418 36667 75207 36667 73542 75207 91445 64418 3222 36667 96990 73542 61771 96990 33073 22698 32560 33073 24210 33073 38905 75207 46243 75207 89600 89600 11756 36667 94609 89600 6427 3222 46213 11756 43560 46243 50875 36667 45066 24210 54458 36667 80150 22...
output:
2
result:
ok "2"
Test #9:
score: 0
Accepted
time: 25ms
memory: 14296kb
input:
100000 99999 77731 86926 77731 23800 86926 89529 23800 33493 86926 30923 23800 25737 23800 48382 25737 35288 48382 23623 35288 83350 35288 43718 89529 46770 30923 29 30923 73178 86926 8382 46770 75585 48382 67116 30923 20689 30923 97292 23800 82313 35288 85630 82313 74213 86926 48620 97292 86647 257...
output:
2
result:
ok "2"
Test #10:
score: 0
Accepted
time: 28ms
memory: 14016kb
input:
100000 99999 4582 99058 99058 87803 87803 5778 5778 21286 99058 64435 5778 25340 99058 84070 99058 92757 87803 48753 21286 71681 21286 50429 71681 22737 21286 48717 48717 81253 64435 23411 5778 30866 81253 76210 50429 16277 81253 16082 99058 32379 84070 95446 76210 40309 76210 35756 25340 71091 2273...
output:
2
result:
ok "2"
Test #11:
score: 0
Accepted
time: 37ms
memory: 14216kb
input:
100000 99999 34790 25024 25024 36551 34790 82646 82646 38938 25024 1562 34790 95790 1562 76262 76262 24681 38938 4943 95790 8669 95790 88401 4943 41293 38938 21530 41293 66721 34790 9066 25024 73316 76262 47595 25024 59910 66721 46517 82646 46936 21530 22361 9066 94253 1562 46296 94253 13074 59910 7...
output:
2
result:
ok "2"
Test #12:
score: 0
Accepted
time: 28ms
memory: 14032kb
input:
100000 99999 98079 73822 73822 63887 73822 71664 98079 65268 65268 72803 71664 77367 65268 85207 77367 39346 65268 55506 63887 49410 85207 35890 55506 51351 85207 87756 51351 47722 87756 31267 35890 91571 39346 9577 31267 31563 91571 59354 87756 27975 85207 59323 27975 34647 63887 52810 31267 83138 ...
output:
2
result:
ok "2"
Test #13:
score: 0
Accepted
time: 29ms
memory: 22148kb
input:
100000 100000 42276 12823 12823 87747 87747 59217 59217 2160 2160 85115 85115 75999 75999 74783 74783 84010 84010 20464 20464 41872 41872 31981 31981 2637 2637 97876 97876 70375 70375 63190 63190 65186 65186 42079 42079 60599 60599 76194 76194 30514 30514 69887 69887 87790 87790 88443 88443 63301 63...
output:
1
result:
ok "1"
Test #14:
score: 0
Accepted
time: 34ms
memory: 12048kb
input:
100000 99839 3777 83777 92737 22487 3405 34804 3405 63348 71869 16450 25024 77034 45886 70138 46420 99380 71372 15729 62782 59134 62782 17644 40931 60627 41776 72468 26424 19072 26424 62020 82982 49540 57857 19904 13263 65383 30740 28382 30740 59687 76880 49124 88187 10493 56456 27193 56456 95532 76...
output:
0
result:
ok "0"
Test #15:
score: 0
Accepted
time: 41ms
memory: 13364kb
input:
100000 99846 66429 19818 1142 65323 89629 2650 89629 42870 60529 13997 20679 78690 20679 5269 8110 28183 34782 58319 26797 17740 21871 93617 83053 29948 14688 55200 52483 73309 56841 6633 56841 55711 95177 89002 57442 17594 16875 7796 16875 8418 33959 24119 33959 33295 67593 42353 36122 96814 36122 ...
output:
1
result:
ok "1"
Test #16:
score: 0
Accepted
time: 32ms
memory: 12052kb
input:
100000 99840 61287 64073 89052 6689 89052 74027 83146 40301 55950 89689 89833 57298 89833 42280 19736 77515 19736 50538 31174 39104 14153 51424 14153 31424 56843 90058 46315 9861 81108 51034 47276 31883 47276 13174 25797 42555 18853 97994 67050 80142 7186 30565 45598 65037 72065 47586 72065 52587 44...
output:
0
result:
ok "0"
Test #17:
score: 0
Accepted
time: 29ms
memory: 12084kb
input:
100000 99837 52632 49066 8207 69824 92267 29339 87828 81159 86585 34918 5072 88375 5072 46372 4237 72777 4237 66222 32455 3061 17684 42281 41275 34536 72839 74066 45095 66825 45095 188 31633 52839 14240 7205 14240 62813 37523 40559 37523 22436 95403 86964 95403 75 24404 73 54534 32797 46562 88745 70...
output:
0
result:
ok "0"
Test #18:
score: 0
Accepted
time: 59ms
memory: 17152kb
input:
100000 200000 91756 69297 91756 4545 91756 53749 91756 54529 91756 72391 91756 1260 91756 94514 69297 56396 69297 94148 69297 44667 69297 73169 69297 81731 19501 62537 19501 96669 19501 78118 19501 59314 19501 21054 19501 96372 19501 39387 19501 50363 19501 80139 19501 8413 34623 10037 34623 20572 1...
output:
0
result:
ok "0"
Test #19:
score: -100
Wrong Answer
time: 54ms
memory: 17188kb
input:
100000 199999 94566 78687 94566 29032 94566 67782 94566 6508 22336 61573 22336 97677 22336 16991 22336 37766 22336 58704 22336 6768 22336 60250 22336 33412 22336 11114 56860 62498 56860 75679 56860 66179 56860 8667 56860 29468 27072 73747 27072 41786 58625 45299 58625 63322 58625 47995 58625 92457 5...
output:
0
result:
wrong answer 1st words differ - expected: '1', found: '0'