QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90814#5528. Least Annoying Constructive ProblemSorting#WA 2ms3440kbC++1001b2023-03-25 15:52:542023-03-25 15:52:55

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-25 15:52:55]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3440kb
  • [2023-03-25 15:52:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
vector<pair<int,int> >ans;

bool used[501];
int f[501];
int find(int x){
	if(f[x]!=x) f[x]=find(f[x]);
	return f[x];
}
void join(int x,int y){
	x=find(x);y=find(y);
	f[x]=y;
}
int main(){
	ios::sync_with_stdio(false);
	int n;cin >> n;
	ans.push_back({1,3});
	ans.push_back({1,2});
	ans.push_back({2,3});
	for(int i=4; i<=n ;i++){
		for(int j=1; j<i ;j++) used[j]=false;
		vector<pair<int,int> >v;
		for(int j=1; j<i ;j++){
			f[j]=j;
		}
		for(int j=0; j<i-2 ;j++){
			int x=ans[j].fi;
			int y=ans[j].se;
			x=find(x);y=find(y);
			v.push_back({i,x});
			join(x,y);
		}
		v.push_back({i,find(1)});
		int ptr=0;
		int lst=0;
		for(auto c:ans){
			v.push_back(c);
			lst++;
			if(lst==i-2){
				v.push_back(v[ptr++]);
				lst=0;
			}
		}
		v.erase(v.begin(),v.begin()+ptr);
		ans=v;
	}
	for(auto c:ans){
		cout << c.fi << ' ' << c.se << '\n';
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3384kb

input:

3

output:

1 3
1 2
2 3

result:

ok Correct

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3440kb

input:

4

output:

4 3
4 2
1 3
1 2
4 1
2 3

result:

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