QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#624242 | #6110. Squirrel Game | ghosh__# | RE | 0ms | 3844kb | C++23 | 1.6kb | 2024-10-09 15:19:09 | 2024-10-09 15:19:10 |
Judging History
answer
#include <bits/stdc++.h>
#define dbg(x) cerr<< (#x) << ":" << x << endl
using namespace std;
using ll = long long;
using ull = unsigned long long;
map<vector<int>, int> sg;
int n, m, k;
int SG(vector<int> x) {
auto Jud = [&]() {
for (int i = 0; i < n; i++) {
if (x[i]) return 0;
}
return 1;
};
if (sg.count(x)) return sg[x];
if (Jud()) {
return sg[x] = 0;
}
vector<int> vis(100);
for (int i = 0; i < n; i++) {
for (int j = 1; j <= x[i]; j++) {
x[i] -= j;
if (i + k < n)
x[i + k] += j;
vis[SG(x)] = 1;
x[i] += j;
if (i + k < n)
x[i + k] -= j;
}
}
for (int i = 0; ; i++) {
if (!vis[i]) {
sg[x] = i;
break;
}
}
return sg[x];
}
void print(vector<int> vec) {
for (auto x: vec) {
cout << x << ' ';
}
cout << sg[vec] << endl;
}
void Solve() {
cin >> m >> n >> k;
vector<int> vec(n);
for (auto &x : vec) {
cin >> x;
}
for (int i = vec.size() - 1; i >= 0; i--) {
if (i)
vec[i] = vec[i] - vec[i - 1] - 1;
else vec[i]--;
}
//cout << SG(vec) << endl;
if (SG(vec)) cout << "Twinkle\n";
else cout << "Nova\n";
/* for (auto [vec, val]: sg) {
print(vec);
} */
}
int main() {
// freopen("in", "r", stdin);
//freopen("out", "w", stdout);
int T = 1;
while (T--){
Solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3836kb
input:
7 3 2 1 4 7
output:
Nova
result:
ok single line: 'Nova'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
7 3 1 1 4 7
output:
Twinkle
result:
ok single line: 'Twinkle'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
1 1 1 1
output:
Nova
result:
ok single line: 'Nova'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
1 1 10 1
output:
Nova
result:
ok single line: 'Nova'
Test #5:
score: -100
Runtime Error
input:
100000 1 1 19593