QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#720184#4580. Bicycle TourMansa_KimoyoWA 1ms5992kbC++141.2kb2024-11-07 11:08:242024-11-07 11:08:24

Judging History

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

  • [2024-11-07 11:08:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5992kb
  • [2024-11-07 11:08:24]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define fir first
#define sec second
#define pii pair<int,int> 
#define umap unordered_map
#define ins insert
using namespace std;
const int N=1e5+5;
int n,m;
int a[N],deg[N];
vector<pii> g[N];
namespace Sub1{
	int used[N];
	inline void Main(){
		queue<int> q;
		int ans=0;
		for(int i=1;i<=n;++i)
			if(deg[i]==1)	q.push(i);
		while(!q.empty()){
			int x=q.front();q.pop();
			used[x]=1;
			for(pii p:g[x]){
				int v=p.fir;
				--deg[v];
				if(deg[v]==1)	q.push(v);
			}
		}
		for(int i=1;i<=n;++i){
			for(pii p:g[i]){
				int v=p.fir,w=p.sec;
				if(!used[i] && !used[v])
					ans=max(ans,w);
			}
		}
		for(int i=1;i<=n;++i){
			if(!used[i])	cout<<ans<<' ';
			else	cout<<"-1 ";
		}
		exit(0);
	}
}
namespace Sub2{
	inline void Main(){
		
		exit(0);
	}
}
signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
//	freopen("cycle.in","r",stdin);
//	freopen("cycle.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=n;++i)	cin>>a[i];
	for(int i=1;i<=m;++i){
		int u,v;cin>>u>>v;
		g[u].pb({v,abs(a[u]-a[v])});
		g[v].pb({u,abs(a[u]-a[v])});
		deg[u]++,deg[v]++;
	}
	if(n==m)	Sub1::Main();
	Sub2::Main();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8 11
5 2 7 0 10 6 6 6
1 2
1 3
2 3
2 4
2 5
2 7
3 5
1 6
6 7
6 8
7 8

output:


result:

wrong answer 1st lines differ - expected: '4 4 5 -1 8 0 0 0', found: ''