QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#466350#1092. Burnished Security UpdatesKevin5307WA 1ms3604kbC++231.2kb2024-07-07 18:40:582024-07-07 18:40:58

Judging History

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

  • [2024-07-07 18:40:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3604kb
  • [2024-07-07 18:40:58]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int cnt[2];
int color[300300];
vector<int> G[300300];
void dfs(int u,int c)
{
	cnt[c-1]++;
	color[u]=c;
	for(auto v:G[u])
		if(!color[v])
			dfs(v,3-c);
		else if(color[v]==c)
			die("-1");
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	while(m--)
	{
		int u,v;
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(color[i])
		{
			cnt[0]=cnt[1]=0;
			dfs(i,1);
			ans+=min(cnt[0],cnt[1]);
		}
	cout<<ans<<endl;
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3604kb

input:

4 2
1 2
3 4

output:

0

result:

wrong answer 1st numbers differ - expected: '2', found: '0'