QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#284122#5689. 喵了个喵 IIsimonG#WA 66ms14900kbC++141.4kb2023-12-16 10:27:342023-12-16 10:27:35

Judging History

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

  • [2023-12-16 10:27:35]
  • 评测
  • 测评结果:WA
  • 用时:66ms
  • 内存:14900kb
  • [2023-12-16 10:27:34]
  • 提交

answer

#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<random>
using namespace std;
const int N=2e5+10,mod=998244353;
int n,m,a[N],fa[N];
int val[N],col[N];
vector<int> b;
vector<int> pos[N];
vector<pair<int,int>> g;
int getf(int x) {
	if(fa[x]==x) return x;
	return fa[x]=getf(fa[x]);
}
bool merge(int x,int y) {
	int fx=getf(x),fy=getf(y);
	if(fx==fy) return false;
	else return fa[fx]=fy,true;
}
int main() {
	scanf("%d",&n); n*=4;
	for(int i=1; i<=n; i++) scanf("%d",&a[i]),b.push_back(a[i]);
	sort(b.begin(),b.end());
	m=unique(b.begin(),b.end())-b.begin();
	b.resize(m);
	for(int i=1; i<=n; i++) {
		a[i]=lower_bound(b.begin(),b.end(),a[i])-b.begin()+1;	
		pos[a[i]].push_back(i);
	}
	for(int i=1; i<=m; i++) {
		int cnt=pos[i].size();
		if(cnt&1) return printf("NO\n"),0;
		for(int j=0; j<cnt; j+=2)
			g.push_back({pos[i][j],pos[i][j+1]});
	}
	sort(g.begin(),g.end());
	int num=m,mr=g[0].second;
	for(int i=1; i<=m; i++) fa[i]=i;
	for(int i=1; i<(int)g.size(); i++) {
		if(g[i].first<g[i-1].second) {
			if(merge(a[g[i].first],a[g[i-1].first])) num--;	
		}
		if(g[i].second<mr) return printf("NO\n"),0;
		mr=max(mr,g[i].second);
	}
	printf("YES\n");
	for(int i=1; i<=m; i++) getf(i);
	for(int i=1; i<=n; i++) {
		int o=0;
		for(int j:pos[i]) {
			col[j]=o;
			o^=1;
		}
	}
	for(int i=1; i<=n; i++) printf("%d",col[i]);
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 66ms
memory: 14900kb

input:

50000
12725 41478 2443 1096 36968 36898 3393 45898 43154 26629 22985 37972 13935 25628 40196 40293 39791 29109 455 45812 12634 21086 8928 13600 25416 30244 15917 22568 35849 40189 27442 28785 46334 25651 7172 30994 39724 27853 47091 21306 42087 31612 22081 23002 17127 15269 11569 8254 41080 30112 31...

output:

YES
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

wrong answer Incorrect