Submission #1379559


Source Code Expand

#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 1e5 + 10;
const int M = (int) 101;
const ll big =  (1LL << 51);
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int INF1 = (int) 1e9 + 3;
const double EPS = (double) 1e-6;
const double PI =  3.14159265359;

int n;
vector<int> a;

int calc(vector<int> v) {
  bool ok = 1;
  for (auto it : v) {
    ok &= it > 1;
  }
  if (ok) {
    return 0;
  }
  int cnt_even = 0;
  for (auto it : v) {
    cnt_even += 1 - it % 2;
  }
  if (cnt_even % 2) {
    return 1;
  } 
  if (sz(v) - cnt_even > 1) {
    return 0;
  } 
  if (sz(v) == cnt_even) {
    //what?
    return 0;
  }
  int gcd = 0;
  vector<int> g = v;
  for (auto &it : g) {
    it -= it % 2;
    gcd = __gcd(gcd, it);
  }
  for (auto &it : g) {
    it /= gcd;
  }
  return !calc(g);
} 


int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    cout << (calc(a) ? "First" : "Second");
    return 0;
}

Submission Info

Submission Time
Task D - Decrementing
User Nurlykhan
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1577 Byte
Status RE
Exec Time 97 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1000
Status
AC × 2
WA × 1
AC × 23
WA × 19
RE × 1
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 WA 40 ms 1024 KB
in10.txt WA 46 ms 1024 KB
in11.txt WA 40 ms 1024 KB
in12.txt WA 40 ms 1024 KB
in13.txt AC 40 ms 1024 KB
in14.txt AC 40 ms 1024 KB
in15.txt WA 40 ms 1024 KB
in16.txt WA 41 ms 1024 KB
in17.txt WA 40 ms 1024 KB
in18.txt AC 41 ms 1024 KB
in19.txt AC 36 ms 896 KB
in2.txt WA 40 ms 1024 KB
in20.txt AC 37 ms 896 KB
in21.txt WA 41 ms 1024 KB
in22.txt WA 41 ms 1024 KB
in23.txt AC 41 ms 1024 KB
in24.txt WA 41 ms 1024 KB
in25.txt AC 38 ms 1024 KB
in26.txt AC 41 ms 1024 KB
in27.txt WA 38 ms 1024 KB
in28.txt AC 41 ms 1024 KB
in29.txt AC 38 ms 1024 KB
in3.txt WA 42 ms 1024 KB
in30.txt AC 41 ms 1024 KB
in31.txt AC 40 ms 1024 KB
in32.txt AC 40 ms 1024 KB
in33.txt AC 39 ms 1024 KB
in34.txt AC 41 ms 1024 KB
in35.txt AC 40 ms 1024 KB
in36.txt RE 97 ms 256 KB
in37.txt AC 1 ms 256 KB
in4.txt WA 41 ms 1024 KB
in5.txt AC 40 ms 1024 KB
in6.txt AC 40 ms 1024 KB
in7.txt WA 40 ms 1024 KB
in8.txt WA 40 ms 1024 KB
in9.txt WA 40 ms 1024 KB
sample1.txt WA 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB