QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#561552 | #9237. Message | bulijiojiodibuliduo# | 10 | 74ms | 4116kb | C++17 | 2.8kb | 2024-09-12 23:44:02 | 2024-09-12 23:44:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
//#define LOCAL
#ifdef LOCAL
void send_message(std::vector<bool> M, std::vector<bool> C);
std::vector<bool> send_packet(std::vector<bool> A);
std::vector<bool> receive_message(std::vector<std::vector<bool>> R);
#else
#include "message.h"
#endif
int ext=5;
int B=4;
int blen=65;
int pad[10100],xbit[10100];
void send_message(std::vector<bool> M, std::vector<bool> C) {
mt19937 rng(12345);
rep(i,0,blen) pad[i]=rng()%2;
rep(i,0,3000) xbit[i]=rng()%2;
int m=blen-SZ(M)-1;
M.pb(pad[m]^1);
per(i,0,m) M.pb(pad[i]);
VI gd;
rep(i,0,31) if (C[i]==0) gd.pb(i);
int cc=0;
rep(i,0,B) {
vector<bool> bs(31,false);
rep(j,0,16) bs[gd[j]]=M[i*16+j];
rep(j,0,31) bs[j]=bs[j]^xbit[cc++];
send_packet(bs);
}
rep(i,0,ext) {
vector<bool> bs(31,false);
rep(j,1,16) bs[gd[j]]=((gd[j]-gd[j-1])>>i)&1;
if (i==ext-1) bs[gd[0]]=M[blen-1]; else {
bs[gd[0]]=((gd[0]+31-gd[15])>>i)&1;
}
rep(j,0,31) bs[j]=bs[j]^xbit[cc++];
send_packet(bs);
}
}
int cb[1111],way;
std::vector<bool> receive_message(std::vector<std::vector<bool>> RR) {
vector<VI> R(SZ(RR),VI(31,0));
rep(i,0,SZ(R)) rep(j,0,31) R[i][j]=RR[i][j];
mt19937 rng(12345);
rep(i,0,blen) pad[i]=rng()%2;
rep(i,0,3000) xbit[i]=rng()%2;
int cc=0;
VI gd;
way=0;
rep(i,0,SZ(R)) rep(j,0,31) R[i][j]=R[i][j]^xbit[cc++];
function<void(int,int)> dfs=[&](int bit,int dep) {
if (bit<dep) return;
if (dep==0) {
cb[dep]=bit;
int w=0;
rep(i,0,ext-1) w+=(R[B+i][bit]<<i);
if ((cb[0]+31-cb[15])%(1<<(ext-1))==w) {
//rep(i,0,16) printf("%d ",cb[i]); puts("");
gd=VI(cb,cb+16);
way+=1;
}
} else {
cb[dep]=bit;
int w=0;
rep(i,0,ext) w+=(R[B+i][bit]<<i);
per(j,0,bit) if ((bit-j)%(1<<ext)==w) dfs(j,dep-1);
}
};
per(i,0,31) dfs(i,15);
assert(way==1);
vector<bool> seq;
rep(i,0,B) {
vector<bool> bs(31,false);
rep(j,0,16) seq.pb(R[i][gd[j]]);
}
seq.pb(R[B+ext-1][gd[0]]);
//rep(i,0,SZ(seq)) printf("%d",(int)seq[i]); puts("seq");
int c=0;
while (seq.back()==pad[c]) seq.pop_back(),c++;
seq.pop_back();
return seq;
}
詳細信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 66ms
memory: 3760kb
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
Manager to Checker
1
result:
points 1.0
Test #2:
score: 10
Accepted
time: 62ms
memory: 3756kb
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
Manager to Checker
1
result:
points 1.0
Test #3:
score: 10
Accepted
time: 74ms
memory: 4116kb
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
Manager to Checker
1
result:
points 1.0
Test #4:
score: 10
Accepted
time: 61ms
memory: 3764kb
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
Manager to Checker
1
result:
points 1.0
Test #5:
score: 10
Accepted
time: 45ms
memory: 3820kb
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
Manager to Checker
1
result:
points 1.0
Test #6:
score: 10
Accepted
time: 38ms
memory: 4012kb
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
Manager to Checker
1
result:
points 1.0
Test #7:
score: 10
Accepted
time: 34ms
memory: 3820kb
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
Manager to Checker
1
result:
points 1.0
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 64ms
memory: 3836kb
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
Manager to Checker
0 ing with message 'decoded message is incorrect' Sending secret with code DIE to mgr2sol[1] Quitting with result code 1
result:
wrong output format Extra information in the output file