QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#785576#9783. Duloc Networkucup-team4975WA 1ms3828kbC++232.8kb2024-11-26 18:20:442024-11-26 18:20:44

Judging History

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

  • [2024-11-26 18:20:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3828kb
  • [2024-11-26 18:20:44]
  • 提交

answer

#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el endl

#ifdef LOCAL
#define FINISH cerr << "FINISH" << endl;
#else
#define FINISH ;
#endif

#ifdef LOCAL
#define debug(x) cerr << setw(4) << #x << " == " << x << endl
#else
#define debug(x)
#endif

#ifdef LOCAL
#define debugv(x)                   \
    cerr << setw(4) << #x << ":: "; \
    for (auto i : x)                \
        cerr << i << " ";           \
    cerr << endl
#else
#define debugv(x)
#endif

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
ostream& operator<<(ostream& out, PII& x)
{
    out << x.fir << " " << x.sec << endl;
    return out;
}

const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int N = 200020;

int con[205]={};
int n;

string qstr(int x){
    string res(n,'0');
    for(int i=x;i<con[x];i++){
        res[i]='1';
    }
    return res;
}
string qstr(int x,int y){
    string res(n,'0');
    for(int i=x;i<con[x];i++){
        res[i]='1';
    }
    for(int i=y;i<con[y];i++){
        res[i]='1';
    }
    return res;
}
int totq = 0;
bool query(int a1,int a2){
    int c1,c2,c12;
    totq++;
    assert(totq <= 3500);
    cout<< "? " <<qstr(a1)<<el;
    cin>>c1;
    if (c1 == 0) {
        cout << "! 0" << el;
        exit(0);
    }

    totq++;
    assert(totq <= 3500);
    cout<< "? " <<qstr(a2)<<el;
    cin>>c2;
    if (c2 == 0) {
        cout << "! 0" << el;
        exit(0);
    }

    totq++;
    assert(totq <= 3500);
    
    cout<< "? " <<qstr(a1,a2)<<el;
   
    cin>>c12;
    if (c12 == 0) {
        cout << "! 0" << el;
        exit(0);
    }

    if(c1+c2-c12==0){
        return false;
    }
    else return true;
}
int p[330];
void solve()
{
    cin>>n;
    if (n == 1) {
        cout << "! 1" << el;
        return; 
    }
    for (int i = 0; i < n; i++) {
        p[i] = i;
    }
    random_shuffle(p, p + n);
    p[n] = n;
    for(int i=0;i<n;i++)con[p[i]]=p[i+1];
    while(1){
        if(con[0]==n){
            break;
        }
        vector<int> tmp;
        tmp.push_back(0);
        for(int i=p[0];con[i]<n;i=con[i]){
            tmp.push_back(con[i]);
            if(query(i,con[i]))tmp.pop_back();
        }
        tmp.push_back(n);
        bool flag=0;
        for(int i=p[0];i<tmp.size()-1;i++){
            if(con[tmp[i]]!=tmp[i+1]){
                flag=1;
                con[tmp[i]]=tmp[i+1];
            }
        }
        if(!flag){
            cout<<"! 0"<<el;
            return ;
        }
    }
    cout<<"! 1"<<el;
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3828kb

input:

4
1
0

output:

? 1110
? 0000
! 0

result:

wrong answer Wrong answer.