結果
問題 | No.103 素因数ゲーム リターンズ |
ユーザー | xxxasdfghjk |
提出日時 | 2018-09-12 01:07:26 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,410 bytes |
コンパイル時間 | 974 ms |
コンパイル使用メモリ | 89,580 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-06-24 20:17:47 |
合計ジャッジ時間 | 1,953 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
12,244 KB |
testcase_01 | AC | 4 ms
11,720 KB |
testcase_02 | AC | 3 ms
11,592 KB |
testcase_03 | WA | - |
testcase_04 | AC | 4 ms
12,096 KB |
testcase_05 | AC | 4 ms
11,780 KB |
testcase_06 | WA | - |
testcase_07 | AC | 4 ms
11,748 KB |
testcase_08 | AC | 4 ms
11,592 KB |
testcase_09 | AC | 3 ms
11,592 KB |
testcase_10 | AC | 3 ms
11,592 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 4 ms
11,888 KB |
testcase_14 | AC | 4 ms
11,724 KB |
testcase_15 | AC | 4 ms
12,240 KB |
testcase_16 | AC | 4 ms
13,640 KB |
testcase_17 | AC | 4 ms
12,536 KB |
testcase_18 | WA | - |
testcase_19 | AC | 4 ms
11,988 KB |
testcase_20 | AC | 4 ms
11,592 KB |
testcase_21 | AC | 4 ms
11,724 KB |
testcase_22 | AC | 4 ms
11,596 KB |
testcase_23 | AC | 4 ms
12,048 KB |
testcase_24 | AC | 6 ms
12,468 KB |
コンパイルメッセージ
main.cpp: In function ‘int ncrset()’: main.cpp:54:1: warning: no return statement in function returning non-void [-Wreturn-type] 54 | } | ^
ソースコード
#include<cstdio> #include<queue> #include<utility> #include<cstring> #include<stack> #include<algorithm> #include<cmath> #include<iostream> #include<map> #define MAX_N 100001 #define INF 2147483647 #define REP(i,n) for(int i=0;i<(int)(n);i++) void init(int n); int find(int n); void unite(int x,int y); bool same(int x, int y); int dx[4] = {1,0,0,-1}; int dy[4] = {0,1,-1,0}; using namespace std; typedef long long int ll; struct edge{ int from,to,cost; }; typedef vector<vector<edge> > AdjList; AdjList graph; typedef pair<int , int> P; bool comp(const edge& e1, const edge& e2){ return e1.cost < e2.cost; } int E,V; edge es[100001]; int kruskal(){ sort(es,es+E,comp); init(V); int res = 0; for(int i=0;i<E;i++){ edge e = es[i]; if(!same(e.to,e.from)){ unite(e.to,e.from); res += e.cost; } } return res; } long long int MOD = 1000000007; long long int ruiseki[200001]; int ncrset(){ ruiseki[0] = 1; for(int i=1;i<200001;i++){ ruiseki[i] = (ruiseki[i-1] * i) % MOD; } } long long int powld(long long int x,long long int n){ long long int ans = 1; while(n > 0){ if((n&1) == 1){ ans = (ans*x) % MOD; } x = (x*x) % MOD; n >>= 1; } return ans % MOD; } int ncrgyaku(int n,int r){ long long int gyakuk,gyakur; long long int res = 1,x,y,z; y = powld(ruiseki[r],MOD-2); z = powld(ruiseki[n-r],MOD-2); return (((ruiseki[n]*y) % MOD)*z) % MOD; } int dp[1000][1000][2]; bool solve(int one,int two,int turn){ if(dp[one][two][turn] != -1) return dp[one][two][turn]; if(one == 0 && two == 0) return 1-turn; if(turn){ if((one > 0) && (two > 0)) return dp[one][two][turn] = solve(one-1,two,1-turn) || solve(one+1,two-1,1-turn) || solve(one,two-1,1-turn); else if((one == 0) && (two > 0)){ return dp[one][two][turn] = solve(one+1,two-1,1-turn) || solve(one,two-1,1-turn); }else{ return dp[one][two][turn] = solve(one-1,two,1-turn); } }else{ if(one > 0 && two > 0) return dp[one][two][turn] = solve(one-1,two,1-turn) && solve(one+1,two-1,1-turn) && solve(one,two-1,1-turn); else if(one == 0 && two > 0){ return dp[one][two][turn] = solve(one+1,two-1,1-turn) && solve(one,two-1,1-turn); }else{ return dp[one][two][turn] = solve(one-1,two,1-turn); } } } int main() { REP(i,1000)REP(j,1000)REP(k,2)dp[i][j][k] = -1; int N,M[101],one=0,two=0; cin >> N; REP(i,N)cin >> M[i]; for(int i=0;i<N;i++){ vector<int> v(0); for(int k=2;M[i]!=1;k++){ while(M[i] % k==0){ v.push_back(k); M[i] /= k; } } map<int,int> mp; for(int j=0;j<v.size();j++) mp[v[j]]++; if(v.size() > 0) v.erase((unique(v.begin(),v.end())),v.end()); REP(i,v.size()){ two += mp[v[i]]/2; one += mp[v[i]]%2; } } cout << (solve(one,two,1) ? "Alice": "Bob") << endl; return 0; } int par[MAX_N]; int ranks[MAX_N]; //n要素で初期化 void init(int n){ REP(i,n){ par[i] = i; ranks[i] = 0; } } //木の根を求める int find(int x){ if(par[x] == x){ return x; }else{ return par[x] = find(par[x]); } } void unite(int x,int y){ x = find(x); y = find(y); if(x == y) return ; if(ranks[x] < ranks[y]){ par[x] = y; }else{ par[y] = x; if(ranks[x] == ranks[y]) ranks[x]++; } } bool same(int x, int y){ return find(x) == find(y); }