QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#92586#5528. Least Annoying Constructive ProblemlmeowdnWA 2ms5560kbC++141.5kb2023-03-30 19:24:592023-03-30 19:25:01

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-30 19:25:01]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5560kb
  • [2023-03-30 19:24:59]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define fi first
#define se second
#define eb emplace_back
#define popc __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef unsigned long long ull;
typedef long double ld;

int read() {
	int x=0,w=1; char c=getchar(); 
	while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
	while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
	return x*w;
}

const int N=509;

int n,a[N],tag,b[N],tot,c[N*N],d[N*N],vst[N],jt;

void check() {
	if(tag) n++;
	rep(i,1,n) vst[i]=0;
	rep(i,1,n-1) vst[c[i]]++, vst[d[i]]++;
	for(int i=n,j=1;i!=n-1;i=i%tot+1,j=j%tot+1) {
		vst[c[i]]++, vst[d[i]]++;
		vst[c[j]]--, vst[d[j]]--;
		rep(k,1,n) if(!vst[k]) {
			cerr<<"WA on "<<j+1<<" "<<i<<" "<<k<<endl;
		}
	}
}

signed main() {
	n=read(); if(n%2==0) n--, tag=1;
	rep(i,1,n) a[i]=i;
	rep(i,1,n/2) {
		int x=1;
		for(int i=1;i<=n;i++,x=(x%n+1)%n+1) {
			++tot; ++jt;
			printf("%lld %lld\n",c[tot]=a[x],d[tot]=a[x%n+1]);
			if(tag&&jt%((n-1)/2)==0) {
				rep(i,1,n) vst[i]=0;
				rep(i,tot-(n-1)/2+1,tot) vst[c[i]]=vst[d[i]]=1;
				++tot;
				int y=0; rep(i,1,n) if(!vst[i]) y=i;
				printf("%lld %lld\n",c[tot]=y,d[tot]=n+1);
			}
		}
		for(int i=1;i<=n;i++,x=(x%n+1)%n+1) {
			b[i]=a[x];
		}
		rep(i,1,n) a[i]=b[i];
	}
	check();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 5560kb

input:

3

output:

1 2
3 1
2 3

result:

wrong answer Integer 1 violates the range [4, 3]