# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
411902 |
2021-05-26T08:18:06 Z |
조영욱(#7630) |
Semafor (COI20_semafor) |
C++17 |
|
90 ms |
24696 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<10;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 |
7 ms |
12236 KB |
Output is correct |
2 |
Incorrect |
7 ms |
12236 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
12236 KB |
Output is correct |
2 |
Incorrect |
7 ms |
12236 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
12364 KB |
Output is correct |
2 |
Correct |
14 ms |
12340 KB |
Output is correct |
3 |
Correct |
60 ms |
12364 KB |
Output is correct |
4 |
Correct |
66 ms |
12364 KB |
Output is correct |
5 |
Correct |
69 ms |
12364 KB |
Output is correct |
6 |
Correct |
79 ms |
12408 KB |
Output is correct |
7 |
Correct |
87 ms |
12420 KB |
Output is correct |
8 |
Correct |
90 ms |
12484 KB |
Output is correct |
9 |
Correct |
65 ms |
12388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
20 ms |
24696 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
20 ms |
24696 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
12364 KB |
Output is correct |
2 |
Correct |
14 ms |
12340 KB |
Output is correct |
3 |
Correct |
60 ms |
12364 KB |
Output is correct |
4 |
Correct |
66 ms |
12364 KB |
Output is correct |
5 |
Correct |
69 ms |
12364 KB |
Output is correct |
6 |
Correct |
79 ms |
12408 KB |
Output is correct |
7 |
Correct |
87 ms |
12420 KB |
Output is correct |
8 |
Correct |
90 ms |
12484 KB |
Output is correct |
9 |
Correct |
65 ms |
12388 KB |
Output is correct |
10 |
Runtime error |
20 ms |
24696 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |