Submission #954222

#TimeUsernameProblemLanguageResultExecution timeMemory
954222PM1Flight to the Ford (BOI22_communication)C++17
0 / 100
191 ms352 KiB
#include <bits/stdc++.h> #include "communication.h" using namespace std; void encode(int n,int x){ int last=30; for(int i=29;i>=0;i--){ int z=(x&(1<<i))?1:0; int a=send(z),b=send(z); if(a==b){ if(last==30)continue; z=(x&(1<<last))?1:0; a=send(z); b=send(z); if(a==b) last=30; } else last=i; } } pair<int,int> decode(int n){ int last=30; int a,b; for(int i=29;i>=0;i--){ int x=receive(),y=receive(); a+=(x<<i); b+=(y<<i); if(x==y){ if(last==30)continue; x=receive(); y=receive(); if(x==y){ if((a&(1<<last))==(x<<last)) b=a; else a=b; last=30; } else{ if((a&(1<<last))!=(x<<last)) swap(a,b); } } else last=i; } return make_pair(a,b); }

Compilation message (stderr)

communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:29:4: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |   b+=(y<<i);
      |   ~^~~~~~~~
communication.cpp:28:4: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |   a+=(x<<i);
      |   ~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...