QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#775541 | #9783. Duloc Network | ucup-team3584# | WA | 1ms | 3828kb | C++23 | 5.3kb | 2024-11-23 16:11:00 | 2024-11-23 16:11:00 |
Judging History
answer
#include <string.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> using vvvc = vector<vector<vector<T>>>;
template<class T> using pq = priority_queue<T,vector<T>,greater<T>>;
template <class T, class S> inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); }
template <class T, class S> inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); }
int dx4[] = {1,0,-1,0};
int dy4[] = {0,1,0,-1};
#define overload5(a, b, c, d, e, name, ...) name
#define overload4(a, b, c, d, name, ...) name
#define REP0(n) for(ll jidlsjf = 0; jidlsjf < n; ++jidlsjf)
#define REP1(i, n) for(ll i = 0; i < (n); ++i)
#define REP2(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP3(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__)
#define per0(n) for(int jidlsjf = 0; jidlsjf < (n); ++jidlsjf)
#define per1(i, n) for(ll i = (n)-1; i >= 0; --i)
#define per2(i, a, b) for(ll i = (a)-1; i >= b; --i)
#define per3(i, a, b, c) for(ll i = (a)-1; i >= (b); i -= (c))
#define per(...) overload4(__VA_ARGS__, per3, per2, per1, per0)(__VA_ARGS__)
#define setbits(j, n) for(ll iiiii = (n), j = lowbit(iiiii); iiiii; iiiii ^= 1 << j, j = lowbit(iiiii))
#define perm(v) for(bool permrepflag = true; (permrepflag ? exchange(permrepflag, false) : next_permutation(all(v)));)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define drop(s) cout << #s << endl, exit(0)
#define si(c) (int)(c).size()
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{}))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{}))
#define rng(v, l, r) v.begin() + (l), v.begin() + (r)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define SORT(v) sort(all(v))
#define REV(v) reverse(all(v))
#define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end())
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define overload2(_1, _2, name, ...) name
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int v;
cin >> v;
int sum = 0;
vc<pair<vc<int>,int>>tmp;
auto add = [&](vc<int>a,int b) -> pair<vc<int>,int>{
int l = -1,r = si(tmp)-1;
while(l+1 < r) {
int mid = (l+r)/2;
string now = string(v,'0');
int nsum = 0;
rep(i,mid+1) {
nsum += tmp[i].se;
for(int j:tmp[i].fi) {
now[j] = '1';
}
}
for(int i:a) {
now[i] = '1';
}
cout << "? " << now << endl;
int c;
cin >> c;
if(nsum+b == c) {
l = mid;
}
else {
r = mid;
}
}
vc<int>fin;
int fs;
for(auto i:tmp[r].fi) {
fin.pb(i);
}
for(auto i:a) {
fin.pb(i);
}
string now = string(v,'0');
for(auto i:fin) {
now[i] = '1';
}
cout << "? " << now << endl;
cin >> fs;
vc<pair<vc<int>,int>>nxt;
sum = 0;
rep(i,si(tmp)) {
if(i == r) continue;
nxt.pb(tmp[i]);
sum += tmp[i].se;
}
tmp = nxt;
return {fin,fs};
};
rep(i,v) {
string s = string(v,'0');
s[i] = '1';
cout << "? " << s << endl;
int a;
cin >> a;
string t = string(i+1,'1')+string(v-i-1,'0');
cout << "? " << t << endl;
int b;
cin >> b;
if(sum+a == b) {
tmp.pb({{(int)i},a});
}
else {
vc<int>n1 = {(int)i};
int n2 = a;
while(true) {
auto now = add(n1,n2);
n1 = now.fi;
n2 = now.se;
if(sum+now.se == b) {
tmp.pb({n1,n2});
break;
}
}
}
}
if(si(tmp) == 1) {
cout << "! 1" << endl;
}
else {
cout << "! 0" << endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3528kb
input:
4 1 1 3 2 2 2 1 1 2 0 0
output:
? 1000 ? 1000 ? 0100 ? 1100 ? 1100 ? 0010 ? 1110 ? 1110 ? 0001 ? 1111 ? 1111 ! 1
result:
ok Correct answer with 11 queries.
Test #2:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
2 0 0 0 0
output:
? 10 ? 10 ? 01 ? 11 ! 0
result:
ok Correct answer with 4 queries.
Test #3:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
4 1 1 3 2 2 2 1 1 2 0 0
output:
? 1000 ? 1000 ? 0100 ? 1100 ? 1100 ? 0010 ? 1110 ? 1110 ? 0001 ? 1111 ? 1111 ! 1
result:
ok Correct answer with 11 queries.
Test #4:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
2 0 0 0 0
output:
? 10 ? 10 ? 01 ? 11 ! 0
result:
ok Correct answer with 4 queries.
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 3828kb
input:
50 3 3 1 4 4 1 5 5 1 6 6 1 7 7 4 10 10 3 11 11 1 12 12 1 13 13 2 14 14 3 14 14 3 16 16 2 15 15 1 14 14 2 16 16 4 17 17 3 16 16 1 17 17 1 17 17 1 17 17 2 16 16 4 15 15 1 16 16 3 15 15 1 15 15 4 14 14 3 13 13 2 12 12 2 13 13 2 14 14 4 14 14 2 14 14 2 13 13 1 14 14 1 13 13 2 12 12 1 12 12 2 11 11 4 10 ...
output:
? 10000000000000000000000000000000000000000000000000 ? 10000000000000000000000000000000000000000000000000 ? 01000000000000000000000000000000000000000000000000 ? 11000000000000000000000000000000000000000000000000 ? 11000000000000000000000000000000000000000000000000 ? 001000000000000000000000000000000...
result:
wrong answer Wrong answer.