Submission #1474542
Source Code Expand
#include "bits/stdc++.h" using namespace std; int n; int get_grundy(vector<int> a) { set<int> s; bool f = true; for (int i = 0; i < n; i ++) if (a[i] != 1) f = false; if (f) return 0; for (int i = 0; i < n; i ++) { if (a[i] == 1) continue; a[i] --; int gcd = a[0]; for (int j = 1; j < n; j ++) { gcd = __gcd(gcd, a[j]); } for (int j = 0; j < n; j ++) { a[j] /= gcd; } s.insert(get_grundy(a)); for (int j = 0; j < n; j ++) { a[j] *= gcd; } a[i] ++; } int g = 0; while (s.count(g)) g ++; return g; } int main() { cin >> n; vector<int> a(n); for (int i = 0; i < n; i ++) cin >> a[i]; int ans = get_grundy(a); cout << (ans ? "First" : "Second") << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Decrementing |
User | KokiYmgch |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1074 Byte |
Status | TLE |
Exec Time | 2141 ms |
Memory | 578688 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1000 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | TLE | 2138 ms | 574336 KB |
in10.txt | TLE | 2138 ms | 574336 KB |
in11.txt | TLE | 2138 ms | 572800 KB |
in12.txt | TLE | 2141 ms | 578688 KB |
in13.txt | TLE | 2138 ms | 567296 KB |
in14.txt | TLE | 2138 ms | 573696 KB |
in15.txt | TLE | 2138 ms | 570368 KB |
in16.txt | TLE | 2138 ms | 576768 KB |
in17.txt | TLE | 2137 ms | 573184 KB |
in18.txt | TLE | 2138 ms | 572800 KB |
in19.txt | TLE | 2139 ms | 574208 KB |
in2.txt | TLE | 2138 ms | 574336 KB |
in20.txt | TLE | 2139 ms | 573312 KB |
in21.txt | TLE | 2138 ms | 576640 KB |
in22.txt | TLE | 2138 ms | 571264 KB |
in23.txt | TLE | 2138 ms | 564992 KB |
in24.txt | TLE | 2138 ms | 572800 KB |
in25.txt | TLE | 2137 ms | 571264 KB |
in26.txt | TLE | 2138 ms | 575360 KB |
in27.txt | TLE | 2138 ms | 576768 KB |
in28.txt | TLE | 2138 ms | 570880 KB |
in29.txt | TLE | 2138 ms | 574720 KB |
in3.txt | TLE | 2139 ms | 572416 KB |
in30.txt | TLE | 2140 ms | 573952 KB |
in31.txt | TLE | 2138 ms | 569600 KB |
in32.txt | TLE | 2138 ms | 572032 KB |
in33.txt | TLE | 2140 ms | 570368 KB |
in34.txt | TLE | 2141 ms | 569600 KB |
in35.txt | TLE | 2141 ms | 572416 KB |
in36.txt | AC | 1 ms | 256 KB |
in37.txt | AC | 1 ms | 256 KB |
in4.txt | TLE | 2138 ms | 572800 KB |
in5.txt | TLE | 2138 ms | 576640 KB |
in6.txt | TLE | 2138 ms | 570880 KB |
in7.txt | TLE | 2140 ms | 575872 KB |
in8.txt | TLE | 2139 ms | 574336 KB |
in9.txt | TLE | 2138 ms | 567680 KB |
sample1.txt | AC | 3 ms | 256 KB |
sample2.txt | AC | 2 ms | 256 KB |
sample3.txt | TLE | 2103 ms | 256 KB |