QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#90814 | #5528. Least Annoying Constructive Problem | Sorting# | WA | 2ms | 3440kb | C++ | 1001b | 2023-03-25 15:52:54 | 2023-03-25 15:52:55 |
Judging History
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]