Submission #1873853
Source Code Expand
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;
#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100
ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
if (n == 0)return 1;
if (n == 1)return x%MOD;
ll res = sq(mod_pow(x, n / 2));
res %= MOD;
if (n % 2 == 1) {
res *= x;
res %= MOD;
}
return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }
int x[5][5];
ll dp[1 << 25];
bool check(int cnt, int pre, int j) {
int Y = j / 5;
int X = j % 5;
if (Y > 0 && Y < 4) {
int u, l;
if (x[Y - 1][X] == 0) {
if (pre&(1 << (j - 1)))u = -1;
else u = 1;
}
else u = (cnt < x[Y - 1][X]) ? 1 : -1;
if (x[Y + 1][X] == 0) {
if (pre&(1 << (j + 1)))l = -1;
else l = 1;
}
else l = (cnt < x[Y + 1][X]) ? 1 : -1;
if (u*l == -1)return false;
}
if (X > 0 && X < 4) {
int u, l;
if (x[Y][X - 1] == 0) {
if (pre&(1 << (j - 5)))u = -1;
else u = 1;
}
else u = (cnt < x[Y][X - 1]) ? 1 : -1;
if (x[Y][X + 1] == 0) {
if (pre&(1 << (j + 5)))l = -1;
else l = 1;
}
else l = (cnt < x[Y][X + 1]) ? 1 : -1;
if (u*l == -1)return false;
}
return true;
}
int main() {
rep(i, 5) {
rep(j, 5) {
cin >> x[i][j];
}
}
dp[0] = 1;
rep(i, (1 << 25)) {
int cnt = 1;
rep(j, 25)cnt += (i&(1 << j));
//rep(j, 25) {
// if (i&(1 << j) || x[j / 5][j % 5] != 0)continue;
// int pre = i;
// int nxt = i | (1 << j);
// if (check(cnt, pre, j)) {
// dp[nxt] = mod_add(dp[pre], dp[nxt]);
// }
//}
}
cout << dp[(1 << 25) - 1] << endl;
}
Submission Info
Submission Time |
|
Task |
D - 25個の整数 |
User |
jimmy |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2495 Byte |
Status |
WA |
Exec Time |
3 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
Subtask1 |
Subtask2 |
Score / Max Score |
0 / 0 |
0 / 30 |
0 / 70 |
Status |
|
|
|
Set Name |
Test Cases |
Sample |
sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
Subtask1 |
sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, test-1-01.txt, test-1-02.txt, test-1-03.txt, test-1-04.txt, test-1-05.txt, test-1-06.txt, test-1-07.txt, test-1-08.txt, test-1-09.txt, test-1-10.txt, test-1-11.txt, test-1-12.txt, test-1-13.txt, test-1-14.txt, test-1-15.txt |
Subtask2 |
sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, test-1-01.txt, test-1-02.txt, test-1-03.txt, test-1-04.txt, test-1-05.txt, test-1-06.txt, test-1-07.txt, test-1-08.txt, test-1-09.txt, test-1-10.txt, test-1-11.txt, test-1-12.txt, test-1-13.txt, test-1-14.txt, test-1-15.txt, test-2-01.txt, test-2-02.txt, test-2-03.txt, test-2-04.txt, test-2-05.txt, test-2-06.txt, test-2-07.txt, test-2-08.txt, test-2-09.txt, test-2-10.txt |
Case Name |
Status |
Exec Time |
Memory |
sample-01.txt |
WA |
1 ms |
256 KB |
sample-02.txt |
WA |
1 ms |
256 KB |
sample-03.txt |
AC |
1 ms |
256 KB |
sample-04.txt |
WA |
1 ms |
256 KB |
test-1-01.txt |
AC |
1 ms |
256 KB |
test-1-02.txt |
WA |
1 ms |
256 KB |
test-1-03.txt |
WA |
1 ms |
256 KB |
test-1-04.txt |
WA |
1 ms |
256 KB |
test-1-05.txt |
WA |
1 ms |
256 KB |
test-1-06.txt |
WA |
1 ms |
256 KB |
test-1-07.txt |
AC |
1 ms |
256 KB |
test-1-08.txt |
WA |
1 ms |
256 KB |
test-1-09.txt |
WA |
1 ms |
256 KB |
test-1-10.txt |
WA |
1 ms |
256 KB |
test-1-11.txt |
WA |
1 ms |
256 KB |
test-1-12.txt |
WA |
1 ms |
256 KB |
test-1-13.txt |
WA |
1 ms |
256 KB |
test-1-14.txt |
WA |
1 ms |
256 KB |
test-1-15.txt |
WA |
1 ms |
256 KB |
test-2-01.txt |
WA |
1 ms |
256 KB |
test-2-02.txt |
WA |
1 ms |
256 KB |
test-2-03.txt |
WA |
1 ms |
256 KB |
test-2-04.txt |
WA |
1 ms |
256 KB |
test-2-05.txt |
WA |
1 ms |
256 KB |
test-2-06.txt |
WA |
3 ms |
256 KB |
test-2-07.txt |
WA |
1 ms |
256 KB |
test-2-08.txt |
WA |
1 ms |
256 KB |
test-2-09.txt |
WA |
1 ms |
256 KB |
test-2-10.txt |
WA |
1 ms |
256 KB |