답안 #654465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654465 2022-10-31T11:23:15 Z atigun Flight to the Ford (BOI22_communication) C++17
0 / 100
62 ms 1692 KB
#include<bits/stdc++.h>
#include"communication.h"

using namespace std;

void encode(int N, int X) {
  vector<int> v;
  for(int bit = 0; bit <= 2; bit++){
    bool on = (X >> bit)&1;
    v.push_back(send(on));
    v.push_back(send(on));
    while(v.end()[-1] != v.end()[-2])
      v.push_back(send(on));
  }
}

pair<int, int> decode(int N) {
  int solution = 0;
  vector<int> v;
  for(int bit = 0; bit <= 2; bit++){
    bool on = 0;
    v.push_back(receive());
    v.push_back(receive());
    while(v.end()[-1] != v.end()[-2])
      v.push_back(receive());
    if(v.end()[-1])
      solution|= (1<<bit);
  }
  return make_pair(solution, solution);
}

Compilation message

communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:21:10: warning: unused variable 'on' [-Wunused-variable]
   21 |     bool on = 0;
      |          ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1692 KB Output is correct
2 Incorrect 4 ms 288 KB Not correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 62 ms 200 KB Not correct
2 Halted 0 ms 0 KB -