QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#566277 | #8468. Collinear Arrangements | ucup-team1231# | WA | 1ms | 3552kb | C++23 | 3.9kb | 2024-09-15 23:38:24 | 2024-09-15 23:38:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef vector<int> vi;
#define pb push_back
int ans[100000],a[100000],qq = 0;
int query(vi v) {
qq++;
int z;
//cout << "? " << v.size();
int sum = 0;
for (int z: v) sum += a[z];
return sum;
//for (int z: v) cout << " " << z+1;
//cout << endl;
//cin >> z;
return z;
}
vi adjList[100000];
int visited[100000];
int doDFS(int u) {
visited[u] = 1;
for (int v: adjList[u]) {
if (!visited[v]) {
ans[v] = ans[u]^1;
doDFS(v);
}
}
return 0;
}
int main() {
int n;
cin >> n;
int i;
for (i = 0; i < n; i++) a[i] = rand() & 1;
fill(ans,ans+n,-1);
vi rem;
for (i = 0; i < n; i++) rem.pb(i);
while (rem.size() > 11) {
vi things;
for (int i = 0; i < 11; i++) things.pb(rem.back()),rem.pop_back();
vector<vector<int> > queries;
queries.pb({7,8,9,10});
queries.pb({0,3,4,5,7,8,9});
queries.pb({1,5,6,9,10});
queries.pb({2,4,6,8,10});
queries.pb({3,4,5,10});
queries.pb({5,6,7,8});
queries.pb({4,6,7,9});
reverse(queries.begin(),queries.end());
auto Q = [&](vi v) {
vi q;
for (int z: v) q.pb(things[z]);
return q;
};
int z = query(Q(queries[0]));
if ((z == 0) || (z == 4)) {
for (int x: Q(queries[0])) {
ans[x] = z/4;
things.erase(find(things.begin(),things.end(),x));
}
for (int x: things) rem.pb(x);
continue;
}
int z2 = query(Q(queries[1]));
if ((z2 == 0) || (z2 == 4)) {
vi vv = Q(queries[1]);
for (int x: vv) {
ans[x] = z2/4;
}
int zz = z-ans[things[6]]-ans[things[7]];
if ((zz == 0) || (zz == 2)) {
ans[things[4]] = ans[things[9]] = zz/2;
int a = things[4],b = things[9];
things.erase(find(things.begin(),things.end(),a));
things.erase(find(things.begin(),things.end(),b));
for (int x: vv) {
things.erase(find(things.begin(),things.end(),x));
}
}
else {
adjList[things[9]].pb(things[4]);
int a = things[4],b = things[9];
things.erase(find(things.begin(),things.end(),a));
for (int x: vv) {
things.erase(find(things.begin(),things.end(),x));
}
}
for (int x: things) rem.pb(x);
continue;
}
else {
int ret[7];
ret[0] = z;
ret[1] = z2;
for (int i = 2; i < 7; i++) ret[i] = query(Q(queries[i]));
for (int i = 0; i < (1 << 11); i++) {
int j;
for (j = 0; j < 7; j++) {
int sum = 0;
for (int k: queries[j]) {
if (i & (1 << k)) sum++;
}
if (sum != ret[j]) break;
}
if (j == 7) {
for (j = 0; j < 11; j++) {
if (i & (1 << j)) ans[things[j]] = 1;
else ans[things[j]] = 0;
}
break;
}
}
}
}
while (rem.size() > 0) {
ans[rem.back()] = query({rem.back()});
rem.pop_back();
}
for (i = 0; i < n; i++) if (ans[i] != -1) doDFS(i);
cout << "= ";
for (i = 0; i < n; i++) cout << ans[i];
cout << endl;
for (i = 0; i < n; i++) cout << a[i],assert(a[i] == ans[i]);
cout << endl;
cout << qq << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3552kb
input:
5 3 0 0 2 0 2 1 1 2 0 2 1 1 1 2 1 1 2 2 1 2 2
output:
= 10111 10111 5
result:
wrong output format Expected integer, but "=" found