# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
411903 |
2021-05-26T08:19:42 Z |
조영욱(#7630) |
Semafor (COI20_semafor) |
C++17 |
|
90 ms |
24740 KB |
#include <bits/stdc++.h>
using namespace std;
long long n,k;
int m,x;
int bit[10]={10,2,9,7,18,21,12,3,29,23};
long long dp[1501][1024];
const int mod=1e9+7;
int sbit;
long long ans(int ind,int bt) {
if (ind==0) {
if (bt==sbit) {
return 1;
}
return 0;
}
if (dp[ind][bt]!=-1) {
return dp[ind][bt];
}
if (ind%k==0) {
int flag=0;
if (m==1) {
for(int i=0;i<10;i++) {
if (bt==bit[i]) {
flag=2;
}
}
}
else {
for(int i=0;i<10;i++) {
if (bt/32==bit[i]) {
flag++;
}
if (bt%32==bit[i]) {
flag++;
}
}
}
if (flag!=2) {
dp[ind][bt]=0;
return 0;
}
}
long long ret=0;
for(int i=0;i<5*m;i++) {
ret+=ans(ind-1,bt^(1<<i));
ret%=mod;
}
return dp[ind][bt]=ret;
}
int main(void) {
scanf("%d %lld %lld %d",&m,&n,&k,&x);
memset(dp,-1,sizeof(dp));
if (m==1) {
sbit=bit[x];
}
else {
sbit=bit[x/10]*32+bit[x%10];
}
if (m==1) {
for(int i=0;i<10;i++) {
printf("%lld\n",ans(n,bit[i]));
}
}
else {
for(int i=0;i<10;i++) {
for(int j=0;j<10;j++) {
printf("%lld\n",ans(n,bit[i]*32+bit[j]));
}
}
}
}
Compilation message
semafor.cpp: In function 'int main()':
semafor.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
54 | scanf("%d %lld %lld %d",&m,&n,&k,&x);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
12296 KB |
Output is correct |
2 |
Correct |
6 ms |
12236 KB |
Output is correct |
3 |
Correct |
6 ms |
12236 KB |
Output is correct |
4 |
Correct |
6 ms |
12328 KB |
Output is correct |
5 |
Correct |
6 ms |
12236 KB |
Output is correct |
6 |
Correct |
6 ms |
12324 KB |
Output is correct |
7 |
Correct |
6 ms |
12336 KB |
Output is correct |
8 |
Correct |
6 ms |
12236 KB |
Output is correct |
9 |
Correct |
6 ms |
12236 KB |
Output is correct |
10 |
Correct |
6 ms |
12236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
12296 KB |
Output is correct |
2 |
Correct |
6 ms |
12236 KB |
Output is correct |
3 |
Correct |
6 ms |
12236 KB |
Output is correct |
4 |
Correct |
6 ms |
12328 KB |
Output is correct |
5 |
Correct |
6 ms |
12236 KB |
Output is correct |
6 |
Correct |
6 ms |
12324 KB |
Output is correct |
7 |
Correct |
6 ms |
12336 KB |
Output is correct |
8 |
Correct |
6 ms |
12236 KB |
Output is correct |
9 |
Correct |
6 ms |
12236 KB |
Output is correct |
10 |
Correct |
6 ms |
12236 KB |
Output is correct |
11 |
Runtime error |
18 ms |
24728 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
12312 KB |
Output is correct |
2 |
Correct |
12 ms |
12284 KB |
Output is correct |
3 |
Correct |
63 ms |
12376 KB |
Output is correct |
4 |
Correct |
79 ms |
12392 KB |
Output is correct |
5 |
Correct |
74 ms |
12364 KB |
Output is correct |
6 |
Correct |
79 ms |
12404 KB |
Output is correct |
7 |
Correct |
90 ms |
12420 KB |
Output is correct |
8 |
Correct |
89 ms |
12364 KB |
Output is correct |
9 |
Correct |
68 ms |
12400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
20 ms |
24740 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
20 ms |
24740 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
12312 KB |
Output is correct |
2 |
Correct |
12 ms |
12284 KB |
Output is correct |
3 |
Correct |
63 ms |
12376 KB |
Output is correct |
4 |
Correct |
79 ms |
12392 KB |
Output is correct |
5 |
Correct |
74 ms |
12364 KB |
Output is correct |
6 |
Correct |
79 ms |
12404 KB |
Output is correct |
7 |
Correct |
90 ms |
12420 KB |
Output is correct |
8 |
Correct |
89 ms |
12364 KB |
Output is correct |
9 |
Correct |
68 ms |
12400 KB |
Output is correct |
10 |
Runtime error |
20 ms |
24740 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |