Submission #672082

#TimeUsernameProblemLanguageResultExecution timeMemory
672082alvingogoFlight to the Ford (BOI22_communication)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "communication.h" using namespace std; vector<int> use(vector<int> &a,vector<int> &b,int x,int t){ sort(a.begin(),a.end()); sort(b.begin(),b.end()); int as=a.size(); int bs=b.size(); vector<int> la,ra,lb,rb; if(as+bs<=2){ vector<int> z; for(auto h:a){ z.push_back(h); } for(auto h:b){ z.push_back(h); } if(z.size()==1){ z.push_back(z[0]); } return z; } else if(as+bs==3){ vector<int> g; for(auto h:a){ g.push_back(h); } for(auto h:b){ g.push_back(h); } sort(g.begin(),g.end()); int u=-1; for(int i=0;i<3;i++){ if(g[i]==x){ u=i; } } if(t==0){ return g; } else{ string s[3]={"1111","0001","1000"}; if(u==-1){ string z; for(int j=0;j<4;j++){ z+=char('0'+receive()); } int flag=-1; for(int i=0;i<3;i++){ int lst=0; for(int j=0;j<4;j++){ if(s[i][j]!=z[j]){ if(lst){ flag=i; break; } else{ lst=1; } } else{ lst=0; } } } vector<int> ret; for(int i=0;i<3;i++){ if(i!=flag){ ret.push_back(g[i]); } } return ret; } else{ for(int i=0;i<4;i++){ send(int(s[u][i]-'0')); } return vector<int>(); } } } int nxt=-1; for(int i=0;i<as/2;i++){ if(a[i]==x){ nxt=0; } la.push_back(a[i]); rb.push_back(a[i]); } for(int i=as/2;i<as;i++){ if(a[i]==x){ nxt=1; } ra.push_back(a[i]); lb.push_back(a[i]); } for(int i=0;i<(bs+1)/2;i++){ if(b[i]==x){ nxt=0; } la.push_back(b[i]); } for(int i=(bs+1)/2;i<bs;i++){ if(b[i]==x){ nxt=1; } ra.push_back(b[i]); } int dd; if(nxt==-1){ dd=receive(); } else{ dd=send(nxt); } if(dd==0){ return use(la,lb,x,t); } else{ return use(ra,rb,x,t); } } const int Bd=31647; void encode(int N,int X){ int a=X/Bd; int c=X%Bd; vector<int> v(max(3,N/Bd+2)); iota(v.begin(),v.end(),0); auto e=use(v,vector<int>(),a,0); vector<int> w(Bd); iota(w.begin(),w.end(),0); auto f=use(w,vector<int>(),c,0); vector<int> z; for(auto h:e){ for(auto y:f){ if(h*Bd+y<=0 || h*Bd+y>N){ continue; } z.push_back(h*Bd+y); } } use(z,vector<int>(),X,1); } pair<int,int> decode(int N){ vector<int> v(max(3,N/Bd+2)); iota(v.begin(),v.end(),0); auto e=use(v,vector<int>(),-1,0); vector<int> w(Bd); iota(w.begin(),w.end(),0); auto f=use(w,vector<int>(),-1,0); vector<int> z; for(auto h:e){ for(auto y:f){ if(h*Bd+y<=0 || h*Bd+y>N){ continue; } z.push_back(h*Bd+y); } } auto j=use(z,vector<int>(),-1,1); return {j[0],j[1]}; }

Compilation message (stderr)

communication.cpp: In function 'void encode(int, int)':
communication.cpp:130:18: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>'
  130 |     auto e=use(v,vector<int>(),a,0);
      |                  ^~~~~~~~~~~~~
communication.cpp:5:45: note:   initializing argument 2 of 'std::vector<int> use(std::vector<int>&, std::vector<int>&, int, int)'
    5 | vector<int> use(vector<int> &a,vector<int> &b,int x,int t){
      |                                ~~~~~~~~~~~~~^
communication.cpp:133:18: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>'
  133 |     auto f=use(w,vector<int>(),c,0);
      |                  ^~~~~~~~~~~~~
communication.cpp:5:45: note:   initializing argument 2 of 'std::vector<int> use(std::vector<int>&, std::vector<int>&, int, int)'
    5 | vector<int> use(vector<int> &a,vector<int> &b,int x,int t){
      |                                ~~~~~~~~~~~~~^
communication.cpp:143:11: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>'
  143 |     use(z,vector<int>(),X,1);
      |           ^~~~~~~~~~~~~
communication.cpp:5:45: note:   initializing argument 2 of 'std::vector<int> use(std::vector<int>&, std::vector<int>&, int, int)'
    5 | vector<int> use(vector<int> &a,vector<int> &b,int x,int t){
      |                                ~~~~~~~~~~~~~^
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:149:18: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>'
  149 |     auto e=use(v,vector<int>(),-1,0);
      |                  ^~~~~~~~~~~~~
communication.cpp:5:45: note:   initializing argument 2 of 'std::vector<int> use(std::vector<int>&, std::vector<int>&, int, int)'
    5 | vector<int> use(vector<int> &a,vector<int> &b,int x,int t){
      |                                ~~~~~~~~~~~~~^
communication.cpp:152:18: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>'
  152 |     auto f=use(w,vector<int>(),-1,0);
      |                  ^~~~~~~~~~~~~
communication.cpp:5:45: note:   initializing argument 2 of 'std::vector<int> use(std::vector<int>&, std::vector<int>&, int, int)'
    5 | vector<int> use(vector<int> &a,vector<int> &b,int x,int t){
      |                                ~~~~~~~~~~~~~^
communication.cpp:162:18: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>'
  162 |     auto j=use(z,vector<int>(),-1,1);
      |                  ^~~~~~~~~~~~~
communication.cpp:5:45: note:   initializing argument 2 of 'std::vector<int> use(std::vector<int>&, std::vector<int>&, int, int)'
    5 | vector<int> use(vector<int> &a,vector<int> &b,int x,int t){
      |                                ~~~~~~~~~~~~~^
communication.cpp:163:22: error: could not convert '{<expression error>, <expression error>}' from '<brace-enclosed initializer list>' to 'std::pair<int, int>'
  163 |     return {j[0],j[1]};
      |                      ^
      |                      |
      |                      <brace-enclosed initializer list>