Submission #1072597
Source Code Expand
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll dp[1<<25]; int main(){ ll MOD=1000000007LL; ll used[25],p[25]; ll st[5][5]; for(ll i=0;i<5;i++){ for(ll j=0;j<5;j++){ cin>>st[i][j]; st[i][j]--; if(st[i][j]<0) continue; used[st[i][j]]=1; p[st[i][j]]=i*5+j; } } memset(dp,0,sizeof(dp)); dp[0]=1LL; for(ll i=0;i<25;i++){ ll b=(1<<i)-1; while(b<(1<<25)){ //bitset<25> bi(b); //cout<<bi.to_string()<<" "<<bi.count()<<" "<<dp[b]<<endl; if(dp[b]){ for(ll j=0;j<25;j++){ if((b>>j)&1) continue; if(used[i]&&p[i]!=j) continue; bool f=1; ll y=j/5,x=j%5; if(0<y&&y<4) f&=!(((b>>((y-1)*5+x))&1)^((b>>((y+1)*5+x))&1)); if(0<x&&x<4) f&=!(((b>>(y*5+x-1))&1)^((b>>(y*5+x+1))&1)); if(f) (dp[b+(1<<j)]+=dp[b])%=MOD; } } if(!b) break; ll x=b&-b; ll y=b+x; b=(((b&~y)/x)>>1)|y; } } cout<<dp[(1<<25)-1]<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 25個の整数 |
User | beet |
Language | C++ (GCC 4.9.2) |
Score | 0 |
Code Size | 1018 Byte |
Status | MLE |
Exec Time | 1006 ms |
Memory | 263120 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 | MLE | 989 ms | 263052 KB |
sample-02.txt | MLE | 988 ms | 262988 KB |
sample-03.txt | MLE | 987 ms | 262992 KB |
sample-04.txt | MLE | 985 ms | 262992 KB |
test-1-01.txt | MLE | 986 ms | 262992 KB |
test-1-02.txt | MLE | 985 ms | 263112 KB |
test-1-03.txt | MLE | 985 ms | 262988 KB |
test-1-04.txt | MLE | 990 ms | 263000 KB |
test-1-05.txt | MLE | 991 ms | 262992 KB |
test-1-06.txt | MLE | 1006 ms | 263104 KB |
test-1-07.txt | MLE | 989 ms | 262992 KB |
test-1-08.txt | MLE | 989 ms | 263116 KB |
test-1-09.txt | MLE | 988 ms | 262992 KB |
test-1-10.txt | MLE | 988 ms | 262992 KB |
test-1-11.txt | MLE | 987 ms | 262992 KB |
test-1-12.txt | MLE | 988 ms | 262992 KB |
test-1-13.txt | MLE | 986 ms | 262992 KB |
test-1-14.txt | MLE | 988 ms | 262992 KB |
test-1-15.txt | MLE | 988 ms | 262992 KB |
test-2-01.txt | MLE | 985 ms | 262992 KB |
test-2-02.txt | MLE | 986 ms | 262984 KB |
test-2-03.txt | MLE | 985 ms | 262992 KB |
test-2-04.txt | MLE | 985 ms | 262988 KB |
test-2-05.txt | MLE | 989 ms | 262992 KB |
test-2-06.txt | MLE | 991 ms | 263000 KB |
test-2-07.txt | MLE | 992 ms | 262992 KB |
test-2-08.txt | MLE | 991 ms | 262992 KB |
test-2-09.txt | MLE | 988 ms | 263120 KB |
test-2-10.txt | MLE | 986 ms | 262988 KB |