QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#476477 | #9115. Contour Multiplication | ucup-team3591# | WA | 23ms | 7476kb | C++14 | 1.2kb | 2024-07-13 19:47:28 | 2024-07-13 19:47:28 |
Judging History
answer
#include<cstdio>
#include<vector>
using namespace std;
typedef long long ll;
inline ll read(){
ll x=0;
int f=0,ch=0;
while(ch<48||ch>57) f=(ch=='-'),ch=getchar();
while(ch>47&&ch<58) x=(x<<3)+(x<<1)+(ch&15),ch=getchar();
return f?-x:x;
}
inline void write(ll x,char end=' '){
if(x==0){
putchar('0');
putchar(end);
return;
}
if(x<0) putchar('-'),x=-x;
int ch[70]={0},cnt=0;
while(x){
ch[cnt++]=(int)(x%10);
x/=10;
}
while(cnt--) putchar(ch[cnt]+48);
putchar(end);
}
const int N=1e5+5;
const int M=3e5+5;
#define pii pair<int,int>
int n,k,up;
ll m;
int p[20][N],cnt[20];
int mul[20][N];
ll a[M];
int main(){
n=read(),m=read(),k=read();
up=(1<<n);
for(int i=0;i<up;++i){
int g=i,c=0;
while(g){
if(g&1)
++c;
g>>=1;
}
p[c][++cnt[c]]=i;
}
for(int i=0;i<=n;++i){
for(int j=0;j<up;++j)
mul[i][j]=1;
}
for(int i=1;i<=k;++i){
int c=read(),d=read(),x=read()%m;
mul[d][c]=mul[d][c]*x%m;
}
for(int i=0;i<up;++i) a[i]=1;
for(int i=0;i<=n;++i){
for(int j=0;j<up;++j){
if(mul[i][j]==1) continue;
for(int t=1;t<=cnt[i];++t){
a[p[i][t]^j]=a[p[i][t]^j]*mul[i][j]%m;
}
}
}
for(int i=0;i<up;++i) write(a[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5440kb
input:
3 100 2 0 2 4 3 0 25
output:
1 1 1 0 1 4 4 1
result:
ok 8 tokens
Test #2:
score: 0
Accepted
time: 1ms
memory: 7452kb
input:
4 998244353 7 0 2 4 3 0 25 9 4 37 4 1 16 6 3 8 1 4 68 13 3 97
output:
1552 8 1 9700 1 64 229696 1 8 4 388 8 64 8 68 1
result:
ok 16 tokens
Test #3:
score: 0
Accepted
time: 0ms
memory: 3276kb
input:
1 2 1 0 1 696782227
output:
1 1
result:
ok 2 tokens
Test #4:
score: -100
Wrong Answer
time: 23ms
memory: 7476kb
input:
5 461799503 500000 26 2 741819583 24 4 16805970 5 2 192769861 5 4 365614234 31 0 680795402 23 5 256636931 24 4 150277578 3 1 912506287 27 5 785022824 1 4 645930009 8 2 715559837 3 4 166807726 22 2 584850050 23 1 481241174 7 0 947410124 0 4 588117991 13 5 882053755 16 5 430265734 29 5 324612363 9 4 8...
output:
119038667 300985916 263023156 -63457625 92000128 326469077 228300732 -429249216 323612674 315304297 196246820 -344448511 229067135 -134859967 258210969 -346572996 -50432118 -366818199 -321535632 -293440807 -45610906 47509044 74219651 56855106 232382502 -20017811 -340855108 -75544304 269896957 977204...
result:
wrong answer 1st words differ - expected: '0', found: '119038667'