QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#798089 | #9783. Duloc Network | MrPavlito | WA | 1ms | 3844kb | C++17 | 2.0kb | 2024-12-04 03:29:00 | 2024-12-04 03:29:01 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
//#define endl "\n"
#define pii pair<int,int>
using namespace std;
const int MAXN = 1e5+5;
const int mod7 = 1e9+7;
const long long inf = 1e18;
int n;
int query(string s)
{
cout << "? " << s << endl;
cout.flush();
int x;
cin >> x;
return x;
}
string craft(vector<int>& niz)
{
string s;
for(int i=0; i<n; i++)s+='0';
for(auto x: niz)s[x] = '1';
return s;
}
void guess(bool t)
{
if(t)cout << "! 1" << endl;
else cout << "! 0" << endl;
}
signed main()
{
ios_base::sync_with_stdio(false),cin.tie(0), cout.tie(0);
int tt=1;
//cin >> tt;
while(tt--)
{
cin >> n;
vector<int> cnt(n+1);
string s;
for(int i=0; i<n; i++)s+='0';
vector<int> org;
for(int i=0; i<n; i++)
{
s[i] = '1';
cnt[i] = query(s);
s[i] = '0';
}
org.pb(0);
bool resenje = 1;
for(int i = 1; i<n; i++)
{
int l = i;
int r = n-1;
int rez = n;
while(l<=r)
{
int mid = l+r >> 1;
vector<int> niz = org;
for(int j= i; j<=mid; j++)niz.pb(j);
set<int> setic;
for(auto x: niz)setic.insert(x);
int trcnt = 0;
for(auto x:setic)trcnt+= cnt[x];
int trenutno = query(craft(niz));
if(trenutno == trcnt)l = mid+1;
else
{
r = mid-1;
rez = mid;
}
}
if(rez == n)
{
resenje = false;
break;
}
org.pb(rez);
}
guess(resenje);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3844kb
input:
4 1 3 2 2 1 2 1 0
output:
? 1000 ? 0100 ? 0010 ? 0001 ? 1110 ? 1100 ? 1110 ? 1111 ! 1
result:
ok Correct answer with 8 queries.
Test #2:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
2 0 0 0
output:
? 10 ? 01 ? 11 ! 0
result:
ok Correct answer with 3 queries.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
4 1 3 2 2 1 2 1 0
output:
? 1000 ? 0100 ? 0010 ? 0001 ? 1110 ? 1100 ? 1110 ? 1111 ! 1
result:
ok Correct answer with 8 queries.
Test #4:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
2 0 0 0
output:
? 10 ? 01 ? 11 ! 0
result:
ok Correct answer with 3 queries.
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3636kb
input:
50 3 1 1 1 1 4 3 1 1 2 3 3 2 1 2 4 3 1 1 1 2 4 1 3 1 4 3 2 2 2 4 2 2 1 1 2 1 2 4 1 1 3 3 3 6 2 1 3 2 3 14 15 11 6 7 10 15 15 13 9 8 8 14 16 13 8 7 14 16 13 8 8 13 17 14 11 8 13 16 14 12 11 14 17 16 13 12 14 17 15 14 13 15 17 14 14 14 15 17 16 16 14 15 16 17 15 16 15 16 17 14 15 15 15 16 16 14 15 16 ...
output:
? 10000000000000000000000000000000000000000000000000 ? 01000000000000000000000000000000000000000000000000 ? 00100000000000000000000000000000000000000000000000 ? 00010000000000000000000000000000000000000000000000 ? 00001000000000000000000000000000000000000000000000 ? 000001000000000000000000000000000...
result:
wrong answer Wrong answer.