# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
411909 |
2021-05-26T08:37:30 Z |
조영욱(#7630) |
Semafor (COI20_semafor) |
C++17 |
|
24 ms |
2948 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;
struct Matrix {
long long arr[32][32];
};
Matrix multi(Matrix a,Matrix b) {
Matrix ret;
memset(ret.arr,0,sizeof(ret.arr));
for(int i=0;i<32;i++) {
for(int j=0;j<32;j++) {
for(int l=0;l<32;l++) {
ret.arr[i][j]+=a.arr[i][l]*b.arr[l][j];
ret.arr[i][j]%=mod;
}
}
}
return ret;
}
Matrix fastpow(Matrix a,long long b) {
if (b==1) {
return a;
}
if (b%2==1) {
return multi(fastpow(a,b-1),a);
}
Matrix half=fastpow(a,b/2);
return multi(half,half);
}
int main(void) {
scanf("%d %lld %lld %d",&m,&n,&k,&x);
sbit=bit[x];
Matrix mat;
memset(mat.arr,0,sizeof(mat.arr));
for(int i=0;i<32;i++) {
for(int bit=0;bit<5;bit++) {
mat.arr[i][i^(1<<bit)]=1;
}
}
Matrix base0=fastpow(mat,k);
Matrix base;
memset(base.arr,0,sizeof(base.arr));
for(int i=0;i<32;i++) {
bool flag=false;
for(int ii=0;ii<10;ii++) {
if (bit[ii]==i) {
flag=true;
}
}
if (!flag) {
continue;
}
for(int j=0;j<32;j++) {
bool flag=false;
for(int ii=0;ii<10;ii++) {
if (bit[ii]==j) {
flag=true;
}
}
if (!flag) {
continue;
}
base.arr[i][j]=base0.arr[i][j];
}
}
Matrix ret;
if (n<k) {
ret=fastpow(mat,n);
}
else {
ret=fastpow(base,n/k);
if (n%k!=0)
ret=multi(ret,fastpow(mat,n%k));
}
for(int i=0;i<10;i++) {
printf("%lld\n",ret.arr[sbit][bit[i]]);
}
}
Compilation message
semafor.cpp: In function 'int main()':
semafor.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | scanf("%d %lld %lld %d",&m,&n,&k,&x);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
2 ms |
496 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
460 KB |
Output is correct |
9 |
Correct |
2 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
2 ms |
496 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
460 KB |
Output is correct |
9 |
Correct |
2 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
6 ms |
844 KB |
Output is correct |
12 |
Correct |
11 ms |
1228 KB |
Output is correct |
13 |
Correct |
17 ms |
2104 KB |
Output is correct |
14 |
Correct |
24 ms |
2816 KB |
Output is correct |
15 |
Correct |
23 ms |
2560 KB |
Output is correct |
16 |
Correct |
23 ms |
2716 KB |
Output is correct |
17 |
Correct |
21 ms |
2524 KB |
Output is correct |
18 |
Correct |
12 ms |
2508 KB |
Output is correct |
19 |
Correct |
13 ms |
2516 KB |
Output is correct |
20 |
Correct |
23 ms |
2764 KB |
Output is correct |
21 |
Correct |
15 ms |
2948 KB |
Output is correct |
22 |
Correct |
12 ms |
2508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
1356 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
1356 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |