Submission #1098287
Source Code Expand
#include <algorithm> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <vector> #define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i)) #define rep(i,n) FOR(i,0,n) #define pb push_back #define all(v) begin(v), end(v) #define debug(x) cerr<< #x <<": "<<x<<endl #define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vector<int> > vvi; typedef vector<ll> vll; typedef vector<vector<ll> > vvll; template<class T> using vv=vector<vector< T > >; vector<string> player = {"First\n", "Second\n"}; int n; vi a; void execute_gcd() { int ret = a[0]; FOR (i, 1, n) { ret = __gcd(ret, a[i]); } if (ret == 1) { return; } rep (i, n) { a[i] /= ret; } } void judge(int turn) { int odd, even; odd = even = 0; rep (i, n) { if ((a[i]&1) == 1) { odd += 1; } else { even += 1; } } if ((even&1) == 1) { cout << player[turn]; exit(0); } if (odd > 1) { cout << player[1 - turn]; exit(0); } rep (i, n) { if ((a[i]&1) == 1) { if (a[i] == 1) { cout << player[1 - turn]; exit(0); } a[i] -= 1; execute_gcd(); return; } } } int main() { scanf("%d", &n); a.resize(n); rep (i, n) { scanf("%d", &a[i]); } int turn = 0; while (true) { judge(turn); turn = 1 - turn; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Decrementing |
User | tspcx |
Language | C++14 (Clang 3.8.0) |
Score | 1000 |
Code Size | 1837 Byte |
Status | AC |
Exec Time | 44 ms |
Memory | 1272 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1000 / 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 21 ms | 1272 KB |
in10.txt | AC | 15 ms | 640 KB |
in11.txt | AC | 24 ms | 640 KB |
in12.txt | AC | 15 ms | 640 KB |
in13.txt | AC | 21 ms | 640 KB |
in14.txt | AC | 39 ms | 640 KB |
in15.txt | AC | 20 ms | 640 KB |
in16.txt | AC | 37 ms | 640 KB |
in17.txt | AC | 19 ms | 640 KB |
in18.txt | AC | 44 ms | 640 KB |
in19.txt | AC | 23 ms | 640 KB |
in2.txt | AC | 15 ms | 640 KB |
in20.txt | AC | 39 ms | 640 KB |
in21.txt | AC | 25 ms | 640 KB |
in22.txt | AC | 23 ms | 640 KB |
in23.txt | AC | 23 ms | 640 KB |
in24.txt | AC | 26 ms | 640 KB |
in25.txt | AC | 23 ms | 640 KB |
in26.txt | AC | 24 ms | 640 KB |
in27.txt | AC | 24 ms | 640 KB |
in28.txt | AC | 25 ms | 640 KB |
in29.txt | AC | 23 ms | 640 KB |
in3.txt | AC | 15 ms | 640 KB |
in30.txt | AC | 22 ms | 640 KB |
in31.txt | AC | 15 ms | 640 KB |
in32.txt | AC | 15 ms | 640 KB |
in33.txt | AC | 25 ms | 640 KB |
in34.txt | AC | 28 ms | 640 KB |
in35.txt | AC | 25 ms | 640 KB |
in36.txt | AC | 3 ms | 256 KB |
in37.txt | AC | 3 ms | 256 KB |
in4.txt | AC | 15 ms | 640 KB |
in5.txt | AC | 15 ms | 640 KB |
in6.txt | AC | 15 ms | 640 KB |
in7.txt | AC | 15 ms | 640 KB |
in8.txt | AC | 15 ms | 640 KB |
in9.txt | AC | 15 ms | 640 KB |
sample1.txt | AC | 3 ms | 256 KB |
sample2.txt | AC | 3 ms | 256 KB |
sample3.txt | AC | 3 ms | 256 KB |