QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#580619 | #9237. Message | ljga_ | 0 | 0ms | 0kb | C++20 | 1.5kb | 2024-09-21 22:45:38 | 2024-09-21 22:45:39 |
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void send_packet(vector<bool> A);
void send_message(vector<bool> M,vector<bool> C){
M.push_back(0);
while(M.size()<1025)
M.push_back(1);
vector<int> x(31);
vector<int> p;
for(int i=0;i<31;i++)
if(!C[i])
p.push_back(i);
for(int i=0;i<15;i++)
x[p[i]]=p[i+1]-p[i];
x[p[15]]=31+p[0]-p[15];
int pos=0;
for(int t=0;t<66;t++){
vector<bool> m(31);
for(auto i:p){
if(x[i]){
if(x[i]==1)
m[i]=1;
else
m[i]=0;
x[i]--;
}
else{
m[i]=M[pos++];
}
}
send_packet(m);
}
}
vector<bool> receive_message(vector<vector<bool> > R){
vector<bool> f(31);
vector<int> x(31);
for(int t=0;t<66;t++){
for(int i=0;i<31;i++)
if(!f[i]){
x[i]++;
if(R[t][i])
f[i]=1;
}
}
vector<bool> c(31,1);
for(int i=0;i<31;i++){
vector<bool> vis(31);
int cnt=0;
for(int u=i;!vis[u];u=(u+x[u])%31){
vis[u]=1;
cnt++;
}
if(cnt==16){
for(int u=i;cnt--;u=(u+x[u])%31)
c[u]=0;
break;
}
}
vector<bool> m;
for(int t=0;t<66;t++){
for(int i=0;i<31;i++){
if(!c[i]&&x[i])
x[i]--;
else
m.push_back(R[t][i]);
}
}
while(m.back())
m.pop_back();
m.pop_back();
return m;
}
#ifdef LOCAL
void send_packet(vector<bool> a){
for(auto t:a)
cout<<t<<' ';
cout<<endl;
}
int main(){
send_message({0,1,1,0,1,0,1,1},{0,0,0,0,1,1,1,1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,1,1,1,1,0,1,1,0});
return 0;
}
#endif
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Instance #0 Runtime Error
Test #1:
score: 0
Instance #0 Runtime Error
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
Manager to Checker
0 ing with message 'manual RTE, cant read int from grader' Sending secret with code DIE to mgr2sol[1] Quitting with result code 1
result:
Subtask #2:
score: 0
Instance #0 Runtime Error
Test #8:
score: 0
Instance #0 Runtime Error
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
Manager to Checker
0 ing with message 'manual RTE, cant read int from grader' Sending secret with code DIE to mgr2sol[1] Quitting with result code 1