QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#621385 | #5156. Going in Circles | Rafat_Kabir | WA | 14ms | 11048kb | C++20 | 4.2kb | 2024-10-08 14:06:52 | 2024-10-08 14:06:54 |
Judging History
answer
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <time.h>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// to erase in multiset-> less_equal<T> and
// s.erase(s.find_by_order(s.order_of_key(x)))
// lower_bound(x)=>(cannot use the stl lower_bound function)
// ll idx = s.order_of_key(x)
// if(idx == s.size()) -> no lower_bound
// else lb = *s.find_by_order(idx) // as 0-indexing
// idx-1 will give highest value which is strictly less than x
// for upper_bound->do the same with (x+1)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef tuple<ll, ll, ll> t64;
typedef vector<t64> vt64;
typedef vector<vt64> vvt64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef vector<vector<p32> > vvp32;
typedef vector<bool> vb;
ll mod = 1e9+7, MOD = 998244353;
double eps = 1e-12;
// #define forn(i,e) for(ll i = 0; i < e; i++)
#define FOR(s, e, i) for(int i = s; i <= e; i++)
// #define rforn(i,s) for(ll i = s; i >= 0; i--)
#define ROF(s ,e, i) for(int i = s; i >= e; i--)
#define coutAll(A) for(auto asdafas : A) cout << asdafas << " "; cout << "\n";
#define foutAll(A) for(auto asdafas : A) fout << asdafas << " "; cout << "\n";
#define cinAll(A) for(auto &asdafas : A) cin >> asdafas;
#define finAll(A) for(auto &asdafas : A) fin >> asdafas;
#define minpq priority_queue<ll, v64, greater<ll>>
#define maxpq priority_queue<ll>
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
ll inf = LLONG_MAX;
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef pair<ll, ll> pii;
#define MAXN 1000000
void solve(int it)
{
mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());
v32 A(MAXN);
v32 flip(MAXN);
cin >> A[0];
FOR(1, 250, i){
cout << "? right" << endl;
cin >> A[i];
if(rng()%2){
cout << "? flip" << endl;
flip[i] = 1;
int x;
cin >> x;
}
}
// 500 done
FOR(3, 100, n){
bool ok = true;
FOR(1, n, i){
// dp[i] = dp[i-n]^flip[i];
if(A[i+n] != (A[i]^flip[i])){
ok = false;
break;
}
}
if(ok){
cout << "! " << n << endl;
return;
}
}
int cur = 251;
FOR(101, 5000, n){
cout << "? right" << endl;
cin >> A[cur];
if(rng()%2){
cout << "? flip" << endl;
flip[cur] = 1;
int x;
cin >> x;
}
++cur;
cout << "? right" << endl;
cin >> A[cur];
if(rng()%2){
cout << "? flip" << endl;
flip[cur] = 1;
int x;
cin >> x;
}
++cur;
bool ok = true;
FOR(1, n, i){
if(A[i+n] != (A[i]^flip[i])){
ok = false;
break;
}
}
if(ok){
cout << "! " << n << endl;
return;
}
}
}
int main()
{
fast_cin();
ll t = 1;
// cin >> t;
for(int it=1; it<=t; it++)
{
//cout << "Case " << it << ": ";
solve(it);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 8ms
memory: 11048kb
input:
0 1 0 0 1 0 0 1 0 1 1 0 1 0 1 1 1 0 0 1 0 1 0 0 1 1 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 1 0 1 1 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 1 0 0 0 1 0 0 1 1 1 0 1 1 0 1 1 0 1 1 0 0 1 1 0 1 0 1 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 1 1 0 1 0 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 1 ...
output:
? right ? right ? right ? right ? flip ? right ? right ? right ? flip ? right ? flip ? right ? flip ? right ? right ? right ? flip ? right ? flip ? right ? right ? flip ? right ? right ? right ? right ? flip ? right ? flip ? right ? right ? flip ? right ? right ? right ? flip ? right ? right ? right...
result:
ok Queries used; 15178.
Test #2:
score: 0
Accepted
time: 9ms
memory: 10788kb
input:
1 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 1 0 0 1 0 1 0 1 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 ...
output:
? right ? flip ? right ? right ? flip ? right ? right ? right ? right ? right ? right ? flip ? right ? flip ? right ? right ? flip ? right ? flip ? right ? right ? flip ? right ? flip ? right ? right ? flip ? right ? right ? flip ? right ? flip ? right ? flip ? right ? right ? right ? right ? right ...
result:
ok Queries used; 14629.
Test #3:
score: 0
Accepted
time: 14ms
memory: 10956kb
input:
0 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 0 0 1 1 0 0 0 0 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 1 1 0 0 0 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 0 1 0 1 1 0 0 1 1 0 1 0 1 0 0 1 1 1 0 0 0 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 1 1 0 0 1 0 1 0 0 1 0 1 1 0 1 0 1 0 1 ...
output:
? right ? right ? right ? right ? right ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? right ? right ? right ? right ? right ? flip ? right ? right ? right ? flip ? right ? flip ? right ? right ? right ? right ? right ? flip ? right ? flip ? right ? right ? right ? flip ? righ...
result:
ok Queries used; 15087.
Test #4:
score: -100
Wrong Answer
time: 2ms
memory: 10916kb
input:
0 0 1 1 0 1 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 0 1 0 0 1 1 0 1 0 1 0 1 0 1 1 1 0 1 0 0 0 1 0 1 0 1 0 0 1 1 0 1 1 1 0 1 1 1 1 0 0 1 1 0 1 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 1 1 0 0 1 0 0 0 1 0 0 1 0 0 ...
output:
? right ? flip ? right ? right ? flip ? right ? right ? right ? flip ? right ? flip ? right ? right ? right ? right ? flip ? right ? right ? flip ? right ? right ? right ? right ? flip ? right ? flip ? right ? right ? right ? right ? right ? flip ? right ? flip ? right ? right ? right ? right ? flip...
result:
wrong answer Wrong answer: incorrect guess 9 (ans: 4095). Queries used: 362