QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#698464 | #5024. 【模板】双端队列 | 5toubun_no_hanayome# | 15 | 3ms | 3868kb | C++14 | 2.5kb | 2024-11-01 19:46:37 | 2024-11-01 19:46:38 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i = (a);i <= (b);++i)
#define per(i, a, b) for(int i = (a);i >= (b);--i)
#define lc (k << 1)
#define rc (k << 1 | 1)
#define lowbit(x) ((x) & -(x))
#define odd(x) ((x) & 1)
#define even(x) (!odd(x))
#define fir first
#define sec second
#define pb push_back
#define il inline
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define i128 __int128
#define f128 __float128
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << "In Line " << __LINE__ << " the " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> using vc = vector<T>;
template<class Tx, class Ty>
il void chkmx(Tx& x, const Ty y) {x = max<common_type_t<Tx, Ty>>(x, y);}
template<class Tx, class Ty>
il void chkmn(Tx& x, const Ty y) {x = min<common_type_t<Tx, Ty>>(x, y);}
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3fll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
bool ms;
const int N = 1005;
int a[N];
void solve() {
int n;
cin >> n;
rep(i, 1, n)
cin >> a[i];
auto cmp = [&](int x, int y) -> int {
if(x > y)
return 1;
if(x < y)
return -1;
return 0;
};
auto calc = [&](auto&& self, int l, int r, int x, int y) -> int {
if(l == r) {
x ^= a[l];
return cmp(x, y);
}
if(l + 1 == r)
return max(cmp(x ^ a[l], y ^ a[r]), cmp(x ^ a[r], y ^ a[l]));
int r1 = self(self, l + 2, r, x ^ a[l], y ^ a[l + 1]);
int r2 = self(self, l + 1, r - 1, x ^ a[l], y ^ a[r]);
int r3 = self(self, l + 1, r - 1, x ^ a[r], y ^ a[l]);
int r4 = self(self, l, r - 2, x ^ a[r], y ^ a[r - 1]);
if((r1 == 1 && r2 == 1) || (r3 == 1 && r4 == 1))
return 1;
if((r1 >= 0 && r2 >= 0) || (r3 >= 0 && r4 >= 0))
return 0;
return -1;
};
int ans = calc(calc, 1, n, 0, 0);
if(ans == 1)
cout << "First\n";
else if(ans == -1)
cout << "Second\n";
else
cout << "Draw\n";
}
bool mt;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cerr << fabs(&ms - &mt) / 1024 / 1024 << "\n";
int t;
cin >> t;
while(t--)
solve();
cerr << 1e3 * clock() / CLOCKS_PER_SEC << " ms\n";
return 0;
}
詳細信息
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 3ms
memory: 3868kb
input:
40 15 1042186166 1065050038 1052442342 117744385 1044381358 996146407 947617159 1031691934 27328777 130294601 1065311743 1065082111 12845136 941620871 1042177446 15 1068465534 15766217 69219008 95461385 1048542590 1051709438 1048575351 1072652151 978275647 1044381687 999247358 1062194999 1054829887 ...
output:
Second Second Second First First Second Second Draw Draw Draw Draw Second Second Second Second First First Draw Second Second Second Draw Second Draw Draw First Second Second Draw Second First First Second Second First First Second First First Draw
result:
ok 40 tokens
Subtask #2:
score: 0
Time Limit Exceeded
Test #2:
score: 0
Time Limit Exceeded
input:
40 987 1073733087 9437225 570431533 1031755263 1031755251 579873284 571521061 536872960 546353705 43000364 535780827 1065313790 536834043 41953824 503270871 1040175099 8426021 537960961 1054732 545292837 34648585 34603052 546314244 537965060 9439748 41953292 43037189 9447949 536864767 1073698294 503...
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #4:
score: 0
Runtime Error
input:
40 49999 30704571 23631198 10459697 452884 909025 3745220 5633170 29257098 24428644 21991837 21100897 21249665 18667093 13809790 21220831 32750672 29531337 31709216 17139349 4444339 787544 14509794 3855820 201034 13281440 26541636 31476242 10318360 20485824 26793325 8264891 22349828 20554718 7556006...
output:
result:
Subtask #4:
score: 0
Runtime Error
Test #6:
score: 0
Runtime Error
input:
40 49035 1073176430 531291499 1005508607 675350672 368768 867368831 139504132 1321089 134482448 464248170 1068169195 68946580 469491567 738764816 742459920 535197167 531887598 672172545 609558673 608209040 335282031 532674543 72878741 610117777 138447508 398155759 71608464 672172165 402325355 609845...