提出 #70095904


ソースコード 拡げる

// Problem: C - Bipartize
// Contest: AtCoder - Panasonic Programming Contest 2025(AtCoder Beginner Contest 427)
// URL: https://atcoder.jp/contests/abc427/tasks/abc427_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll tttt=1;
	//cin>>tttt;
	while(tttt--)
	{
		ll n,m;
		cin>>n>>m;
		vector<vector<ll>>G(n+7);
		while(m--)
		{
			ll u,v;
			cin>>u>>v;
			G[u].push_back(v);
			G[v].push_back(u);
		}
		ll ans=4e18;
		for(int i=1;i<=n;i++)
		{
			vector<ll>col(n+7,-1);
			ll cnt=0;
			col[i]=0;
			queue<ll>q;
			q.push(i);
			while(!q.empty())
			{
				ll u=q.front();
				//cout<<u<<' ';
				q.pop();
				for(auto v:G[u])
				{
					if(col[v]!=1-col[u]&&col[v]!=-1)
					{
						cnt++;
						//cout<<u<<' '<<v<<'\n';
						continue;
					}
					if(col[v]==-1)q.push(v);
					col[v]=1-col[u];
					
				}
				//cout<<cnt<<'\n';
			}
			ans=min(ans,cnt);
			//cout<<'\n';
		}
		cout<<ans/2<<'\n';
	}
	return 0;
}

提出情報

提出日時
問題 C - Bipartize
ユーザ evilwater
言語 C++ 20 (gcc 12.2)
得点 0
コード長 1100 Byte
結果 WA
実行時間 1 ms
メモリ 3600 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 350
結果
AC × 3
AC × 17
WA × 8
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3480 KiB
00_sample_01.txt AC 1 ms 3472 KiB
00_sample_02.txt AC 1 ms 3408 KiB
01_random_03.txt AC 1 ms 3480 KiB
01_random_04.txt AC 1 ms 3468 KiB
01_random_05.txt AC 1 ms 3524 KiB
01_random_06.txt AC 1 ms 3480 KiB
01_random_07.txt AC 1 ms 3412 KiB
01_random_08.txt AC 1 ms 3472 KiB
01_random_09.txt AC 1 ms 3316 KiB
01_random_10.txt AC 1 ms 3512 KiB
01_random_11.txt AC 1 ms 3412 KiB
01_random_12.txt WA 1 ms 3480 KiB
01_random_13.txt WA 1 ms 3416 KiB
01_random_14.txt WA 1 ms 3468 KiB
01_random_15.txt WA 1 ms 3424 KiB
01_random_16.txt WA 1 ms 3320 KiB
01_random_17.txt WA 1 ms 3524 KiB
01_random_18.txt WA 1 ms 3320 KiB
01_random_19.txt WA 1 ms 3516 KiB
01_random_20.txt AC 1 ms 3436 KiB
01_random_21.txt AC 1 ms 3516 KiB
01_random_22.txt AC 1 ms 3396 KiB
01_random_23.txt AC 1 ms 3600 KiB
01_random_24.txt AC 1 ms 3320 KiB