QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#750816#9484. Colored Complete GraphaYi_7#WA 1ms3792kbC++172.1kb2024-11-15 16:03:052024-11-15 16:03:06

Judging History

This is the latest submission verdict.

  • [2024-11-15 16:03:06]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3792kb
  • [2024-11-15 16:03:05]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define double long double
struct tree{
    char c;
    set<int>h,no;
    vector<pair<int,int>>ans;
};
void solve() {
    int n;
    cin>>n;
    tree a,b;
    a.c='R';
    b.c='B';
    a.h.insert(1);
    b.h.insert(1);
    char ne;
    for(int i=2;i<=n;i++){
        cout<<"? 1 "<<i<<endl;
        cin>>ne;
        if(ne==a.c){
            a.ans.emplace_back(1,i);
            a.h.insert(i);
            b.no.insert(i);
        }
        else{
            b.ans.emplace_back(1,i);
            b.h.insert(i);
            a.no.insert(i);
        }
    }
    if((int)a.h.size()==n){
        cout<<"!"<<endl;
        for(auto &[o,p]:a.ans)cout<<o<<" "<<p<<endl;
        return;
    }
    swap(a,b);
    if((int)a.h.size()==n){
        cout<<"!"<<endl;
        for(auto &[o,p]:a.ans)cout<<o<<" "<<p<<endl;
        return;
    }
    for(int i=2;i<=n;i++){
        if(a.h.count(i)&&b.h.count(i))continue;
        if(b.h.count(i))swap(a,b);
        set<int>cur=a.no;
        for(int j:cur){
            cout<<"? "<<i<<" "<<j<<endl;
            cin>>ne;
            if(ne==a.c){
                a.no.erase(j);
                a.h.insert(j);
                a.ans.emplace_back(i,j);
            }
            else{
                b.no.erase(i);
                b.h.insert(i);
                b.ans.emplace_back(i,j);
            }
            if((int)a.h.size()==n){
                cout<<"!"<<endl;
                for(auto &[o,p]:a.ans)cout<<o<<" "<<p<<endl;
                return;
            }
            swap(a,b);
            if((int)a.h.size()==n){
                cout<<"!"<<endl;
                for(auto &[o,p]:a.ans)cout<<o<<" "<<p<<endl;
                return;
            }


        }
    }



}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout<<setiosflags(ios::fixed)<<setprecision(2);
    int t = 1;
    //std::cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}

詳細信息

Test #1:

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

input:

3
B
R
B

output:

? 1 2
? 1 3
? 2 3
!
1 2
2 3

result:

ok AC

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3780kb

input:

983
B
R
R
B
B
B
B
B
R
B
R
R
R
R
R
R
R
B
B
R
R
B
R
B
R
R
B
B
R
B
R
R
R
R
B
R
B
B
B
R
R
R
B
B
R
R
B
R
B
R
B
B
B
R
B
R
R
B
R
B
B
R
R
R
B
B
B
B
R
B
R
R
B
R
B
B
R
B
R
B
R
B
R
R
R
B
B
B
R
R
B
B
B
R
R
B
R
B
B
B
R
B
B
R
R
B
B
R
R
R
R
B
R
R
B
B
B
R
B
B
B
B
R
B
R
R
B
R
R
R
B
R
R
B
R
R
B
R
R
B
R
B
R
B
B
R
B
R
...

output:

? 1 2
? 1 3
? 1 4
? 1 5
? 1 6
? 1 7
? 1 8
? 1 9
? 1 10
? 1 11
? 1 12
? 1 13
? 1 14
? 1 15
? 1 16
? 1 17
? 1 18
? 1 19
? 1 20
? 1 21
? 1 22
? 1 23
? 1 24
? 1 25
? 1 26
? 1 27
? 1 28
? 1 29
? 1 30
? 1 31
? 1 32
? 1 33
? 1 34
? 1 35
? 1 36
? 1 37
? 1 38
? 1 39
? 1 40
? 1 41
? 1 42
? 1 43
? 1 44
? 1 45
...

result:

wrong answer invalid question