QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#521681#2193. Cactus Revengebachbeo2007WA 0ms3760kbC++231.4kb2024-08-16 13:55:372024-08-16 13:55:38

Judging History

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

  • [2024-08-16 13:55:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3760kb
  • [2024-08-16 13:55:37]
  • 提交

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';
}

詳細信息

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