Created
September 26, 2015 07:38
-
-
Save cympfh/23aabe29b61335e94279 to your computer and use it in GitHub Desktop.
手でカウントさせる二人完全情報有限和うんたらゲーム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define rep(i,n) for(int i=0;i<(n);++i) | |
#define loop for(;;) | |
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl; | |
#define all(v) begin(v),end(v) | |
#define pb push_back | |
#define inf (1e9) | |
#define eps (1e-9) | |
using Integer = long long; | |
using Real = long double; | |
const Real PI = acosl(-1); | |
using P = pair<int, int>; | |
template<class S, class T> inline | |
ostream& operator<<(ostream&os, pair<S,T> p) { | |
return os << '(' << p.first << ", " << p.second << ')'; | |
} | |
template<class S, class T, class U> inline | |
ostream& operator<<(ostream&os, tuple<S,T,U> t) { | |
return os << '(' | |
<< get<0>(t) << ", " | |
<< get<1>(t) << ", " | |
<< get<2>(t) << ')'; | |
} | |
template<class T> inline | |
ostream& operator<<(ostream&os, set<T> v) { | |
os << "(set"; | |
for (T item: v) os << ' ' << item; | |
os << ")"; | |
return os; | |
} | |
template<class T> inline | |
ostream& operator<<(ostream&os, vector<T> v) { | |
if (v.size() == 0) { return os << "(empty)"; } | |
os << v[0]; | |
for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i]; | |
return os; | |
} | |
template<class T> inline | |
istream& operator>>(istream&is, vector<T>&v) { | |
rep (i, v.size()) is >> v[i]; | |
return is; | |
} | |
// ^ > v < | |
int dx[] = { -1, 0, 1, 0 }; | |
int dy[] = { 0, 1, 0, -1 }; | |
using vi = vector<int>; | |
using vvi = vector<vi>; | |
using vd = vector<double>; | |
using vvd = vector<vd>; | |
using vb = vector<bool>; | |
int f[5][5][5][5]; | |
int main() { | |
cin.tie(0); | |
ios::sync_with_stdio(0); | |
cout.setf(ios::fixed); | |
cout.precision(10); | |
random_device dev; | |
mt19937 rand(dev()); | |
stack<tuple<int,int,int,int>> s; | |
rep (i, 5) { | |
rep (j, 5) { | |
if (i == 0 and j == 0) continue; | |
s.push(make_tuple(0, 0, i, j)); | |
f[0][0][i][j] = -1; | |
} | |
} | |
while (not s.empty()) { | |
auto t = s.top(); s.pop(); | |
int i = get<0>(t); | |
int j = get<1>(t); | |
int k = get<2>(t); | |
int l = get<3>(t); | |
int b = f[i][j][k][l]; | |
if (b == 0) continue; | |
if (k != 0) { | |
int i2 = (i+5-k)%5; | |
if (i2 > 0 and f[k][l][i2][j] != 1) { | |
f[k][l][i2][j] = -b; | |
s.push(make_tuple(k, l, i2, j)); // k beats i2 | |
} | |
int j2 = (j+5-k)%5; | |
if (j2 > 0 and f[k][l][i][j2] != 1) { | |
f[k][l][i][j2] = -b; | |
s.push(make_tuple(k, l, i, j2)); | |
} | |
} | |
if (l != 0) { | |
int i2 = (i+5-k)%5; | |
if (i2 > 0 and f[k][l][i2][j] != 1) { | |
f[k][l][i2][j] = -b; | |
s.push(make_tuple(k, l, i2, j)); | |
} | |
int j2 = (j+5-k)%5; | |
if (j2 > 0 and f[k][l][i][j2] != 1) { | |
f[k][l][i][j2] = -b; | |
s.push(make_tuple(k, l, i, j2)); | |
} | |
} | |
} | |
rep (i, 5) | |
rep (j, i+1) | |
rep (k, 5) | |
rep (l, k+1) { | |
cout << make_pair(i,j) << ", " << make_pair(k,l) | |
<< " -- " << f[i][j][k][l] << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment