QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#68603#4888. Decoding The Message275307894aWA 4ms3628kbC++142.1kb2022-12-17 19:23:512022-12-17 19:23:53

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-17 19:23:53]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3628kb
  • [2022-12-17 19:23:51]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n))
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define PB push_back
using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned ll;
using namespace std;const int N=257+5,M=10+5,K=1e5+5,mod=1e9+7,Mod=mod-1,INF=2e9+7;const db eps=1e-5;mt19937 rnd(263082);
int n,X[N],Y[N],m,B[N*2],Bh;
ll mpow(ll x,int y,int p){ll Ans=1;while(y) y&1&&(Ans=Ans*x%p),y>>=1,x=x*x%p;return Ans;}
int GS(int p){
	int Ct=0,i;for(i=1;i<=n;i++) Ct=(Ct+1ll*X[i]*Y[i])%p;if(!Ct) return 0;
	ll Ans=1;for(i=1;Ans&&i<=m;i++) Ans=Ans*i%(p-1);return mpow(Ct,Ans,p);
}
bitset<N> f[N],g[N],Cl;
int CK(){
	int Mx=0,i,j,h;for(i=1;i<=n;i++) Mx=max(Mx,Y[i]);if(m>=514&&m-Mx>=257) return 0;
	Bh=0;for(i=1;i<=n;i++) if(Y[i]==Mx){Mx=0;}else for(j=1;j<=Y[i];j++) B[++Bh]=X[i];
	for(i=0;i<=257;i++) f[i]=Cl;f[0][0]=1;
	for(i=1;i<=Bh;i++){
		for(j=0;j<=min(Bh,m/2);j++) g[j]=f[j],f[j]=Cl;
		for(j=0;j<=min(Bh,m/2);j++){
			for(h=0;h<257;h++) if(g[j][h]) f[j][(h+B[i])%257]=1,f[j+1][(h-B[i]+257)%257]=1;
		}
	}
	for(i=1;i<=n;i++)Mx=max(Mx,Y[i]);for(i=1;i<=n;i++) if(Y[i]==Mx){
		for(j=max(0,m/2-Bh);j<=min(m/2,Y[i]);j++) if(f[m/2-j][(1ll*(Y[i]-2*j)*X[i]%257+257)%257]) return 0;
	}return 0;
}
int GA(){
	if(CK()) return 0;if(m>=12) return 1;
	int i,j;Bh=0;for(i=1;i<=n;i++) for(j=1;j<=Y[i];j++) B[++Bh]=X[i];
	ll As=1;for(i=0;i<(1<<m);i++){
		int Ct=0;for(j=0;j<m;j++) Ct+=(i>>j&1);if(Ct^(m/2)) continue;
		int Ts=0;for(j=1;j<=m;j++) Ts+=(i>>(j-1)&1?-B[j]:B[j]);As=As*(Ts%257+257)%257;
	}
	ll Fc=1;for(i=1;i<=m/2;i++) Fc=Fc*i%256;for(i=1;i<=(m+1)/2;i++) Fc=Fc*i%256;return mpow(As,Fc,257);
}
void Solve(){
	int i,j;scanf("%d",&n);m=0;for(i=1;i<=n;i++) scanf("%d%d",&X[i],&Y[i]),m+=Y[i];
	int A1=GS(3),A2=GS(5),A3=GS(17),A4=GA(); 
	for(i=0;i<65535;i++) if(i%3==A1&&i%5==A2&&i%17==A3&&i%257==A4) {printf("%d\n",i);return;}
}
int main(){
	int t;scanf("%d",&t);while(t--) Solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3628kb

input:

5
1
42 1
2
0 1
1 1
1
239 2
2
1 1
2 1
3
1 1
2 2
3 2

output:

42
256
514
1284
61726

result:

ok 5 number(s): "42 256 514 1284 61726"

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 3576kb

input:

100
1
213 79
1
54 69
1
218 55
1
248 80
1
101 8
1
153 79
1
240 45
1
112 70
1
217 5
1
208 64
1
48 30
1
0 19
1
53 40
1
63 17
1
179 65
1
221 22
1
135 84
1
138 20
1
54 29
1
114 19
1
253 94
1
240 36
1
40 94
1
244 93
1
239 24
1
133 8
1
105 91
1
45 43
1
241 74
1
206 17
1
100 73
1
133 44
1
57 70
1
56 72
1
47...

output:

21846
21846
26215
26215
32896
6426
48060
26215
43570
1
48060
32640
26215
6426
26215
50116
48060
48060
21846
21846
1
48060
26215
21846
21846
32896
48060
48060
1
50116
26215
1
48060
21846
6426
50116
48060
21846
21846
6426
21846
21846
6426
21846
1
26215
26215
26215
21846
15420
48060
22101
26215
26215
1...

result:

wrong answer 4th numbers differ - expected: '59110', found: '26215'