# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
603736 | 2022-07-24T10:35:00 Z | Abdulmohsen1284 | Flight to the Ford (BOI22_communication) | C++17 | 53 ms | 1836 KB |
#include"communication.h" // // --- Sample implementation for the task communication --- // // To compile this program with the sample grader, place: // communication.h communication_sample.cpp sample_grader.cpp // in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory, // left click on "Open in terminal") and enter e.g.: // g++ -std=c++17 communication_sample.cpp sample_grader.cpp // in this folder. This will create a file a.out in the current directory which you can execute from the terminal // as ./a.out // See task statement or sample_grader.cpp for the input specification // #include <bits/stdc++.h> using namespace std; void encode(int N, int X) { long long twos[40],n[40],x[40]; twos[0]=1; for(int i=1;i<=32;i++) twos[i]=twos[i-1]*2; for(int i=1;i>=0;i--) { if(X>=twos[i]) { x[i]=1; X-=twos[i]; } else x[i]=0; } long long bef=send(1),rev=0,calc=1; for(int i=0;i<2;i++) { long long e,w; //cout<<x[i]<<endl<<i<<endl; while(calc>240) { calc=calc; } if(rev%2==0) { calc+=2; e=send(x[i]); w=send(x[i]); } else { calc+=2; w=send(x[i]); e=send(x[i]); } calc++; long long hg=send(1); if(bef==0) { bef=bef; } else if(hg==0) { hg=hg; } else if(e==w) { hg=hg; } else{ rev++; i--; continue; } bef=hg; } //X=send(1); } std::pair<int, int> decode(int N) { //#include <bits/stdc++.h> //using namespace std; long long tw[40],rev=0; tw[0]=1; for(int i=1;i<=32;i++) tw[i]=tw[i-1]*2; long long bef=-1; std::pair <int,int> ret; ret.first=0; ret.second=0; bef=receive(); for(int i=0;i<2;i++) { //long long g=receive(),e=receive(),w=receive(); long long e,g; if(rev%2==0) { g=receive(); e=receive(); } else { e=receive(); g=receive(); } long long w=receive(); if(bef==0) { if(rev%2==0) ret.second+=g*tw[i]; else ret.second+=e*tw[i]; } else if(w==0) { if(rev%2==0) ret.second+=e*tw[i]; else ret.second+=g*tw[i]; } else if(g==e) { ret.second+=g*tw[i]; } else{ rev++; i--; continue; } bef=w; } long long st=ret.first,en=ret.second; ret.first=en; ret.second=en; //cout<<ret.first<<" "<<ret.second; return ret; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 1796 KB | Output is correct |
2 | Correct | 21 ms | 1836 KB | Output is correct |
3 | Incorrect | 4 ms | 200 KB | Not correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 53 ms | 200 KB | Not correct |
2 | Halted | 0 ms | 0 KB | - |