QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#750785 | #9484. Colored Complete Graph | aYi_7# | WA | 5ms | 4108kb | C++17 | 2.1kb | 2024-11-15 15:56:49 | 2024-11-15 15:56:51 |
Judging History
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{
a.no.erase(i);
a.h.insert(i);
a.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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3820kb
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: 5ms
memory: 4108kb
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