QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#186685 | #4912. WereYouLast | hos_lyric# | 12 | 8749ms | 5076kb | C++14 | 2.6kb | 2023-09-24 10:03:48 | 2024-07-04 02:08:14 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
bool query(int);
void modify(int,bool);
bool WereYouLast(int N, int M) {
if (M == 10) {
int x = 0;
for (int i = 0; i < M; ++i) {
if (query(i + 1)) {
x |= 1 << i;
}
}
if (x == (1 << M) - 1) {
return true;
}
for (int i = 0; i < M; ++i) {
modify(i + 1, (x + 1) >> i & 1);
}
return false;
} else {
const int E = 31 - __builtin_clz(N);
int segN = 1;
for (; segN < E; segN <<= 1) {}
auto prod = [&](int u) -> int { return 1000 + u; };
auto lz = [&](int u) -> int { return 2000 + u; };
int u = 1;
for (; u < segN; ) {
const int uL = u << 1;
const int uR = u << 1 | 1;
if (1 < u && query(lz(u))) {
modify(prod(uL), 0); if (uL < segN) modify(lz(uL), 1);
modify(prod(uR), 0); if (uR < segN) modify(lz(uR), 1);
modify(lz(u), 0);
}
if (query(prod(uL))) {
modify(prod(uL), 0); if (uL < segN) modify(lz(uL), 1);
u = uR;
} else {
u = uL;
}
}
if (u >= segN + E) {
return true;
}
if (u == (segN << 1) - 1 && query(prod(u))) {
return true;
}
modify(prod(u), 1);
for (int v = u; (u >>= 1) > 1; v = u) {
const int uL = u << 1;
const int uR = u << 1 | 1;
modify(prod(u), (query(prod(v)) && query(prod(uL ^ uR ^ v))));
}
return false;
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3832kb
input:
1024 10
output:
12345876 10 10
result:
ok Correct Answer. C1 = 10. C2 = 10.
Subtask #2:
score: 2
Acceptable Answer
Test #2:
score: 2
Acceptable Answer
time: 9ms
memory: 4944kb
input:
65536 100000
output:
12345876 14 14
result:
points 0.10 Correct Answer. C1 = 14. C2 = 14.
Subtask #3:
score: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 142ms
memory: 4948kb
input:
1048576 100000
output:
12345876 16 16
result:
points 0.0 Correct Answer. C1 = 16. C2 = 16.
Subtask #4:
score: 0
Wrong Answer
Test #4:
score: 0
Wrong Answer
time: 8749ms
memory: 5076kb
input:
67108864 100000
output:
12345876 16 16
result:
points 0.0 Correct Answer. C1 = 16. C2 = 16.