QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#521681 | #2193. Cactus Revenge | bachbeo2007 | WA | 0ms | 3760kb | C++23 | 1.4kb | 2024-08-16 13:55:37 | 2024-08-16 13:55:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2005;
struct node{
int d,id;
bool operator<(const node &a)const{
return d>a.d;
}
}a[maxn];
vector<pair<int,int>> ans;
void add(int i,int j){
a[i].d--;a[j].d--;
ans.push_back({a[i].id,a[j].id});
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
int n;cin >> n;
for(int i=1;i<=n;i++) cin >> a[i].d,a[i].id=i;
while(true){
sort(a+1,a+n+1);
while(n && !a[n].d) n--;
if(!n) break;
if(a[n].d==1){
int p=1;
for(int i=1;i<=n;i++) if((a[i].d&1) && a[i].d>1){p=i;break;}
if(a[p].d==1 && n>2){
cout << "No\n";
return 0;
}
add(p,n);
}
else if(a[n].d==2){
if(n<3){
cout << "No\n";
return 0;
}
if(a[1].d==2){
for(int i=1;i<=n;i++) add(i,i%n+1);
}
else{
if(a[n-1].d!=2){
cout << "No\n";
return 0;
}
add(n-1,n),add(1,n),add(1,n-1);
}
}
else{
cout << "No\n";
return 0;
}
}
cout << "Yes\n";
for(auto [u,v]:ans) cout << 2 << ' ' << u << ' ' << v << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3760kb
input:
5 2 2 3 2 1
output:
Yes 2 3 5 2 3 1 2 1 2 2 2 4 2 4 3
result:
wrong output format Expected integer, but "Yes" found