답안 #782020

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782020 2023-07-13T14:47:50 Z Dan4Life Data Transfer (IOI19_transfer) C++17
0 / 100
4 ms 2496 KB
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
#define sz(a) a.size()
 
vi get_attachment(vi v) {
	int x = 0, y = 0; vi a;
	for(int i = 0; i < sz(v); i++) if(v[i]) x^=i+1;
	for(int i = 0; i < __lg(sz(v)+1); i++) a.push_back((x>>i)&1), y^=(x>>i)&1;
	a.push_back(y); return a;
}
 
vi retrieve(vi v){
	int x = 0, xx = 0, y = 0, n=sz(v)<99?63:255;
	for(int i = 0; i < n; i++) if(v[i]) x^=i+1;
	for(int i = 0; i < __lg(n+1); i++) if(v[n+i]) xx^=1<<i, y^=1;
	if(v.back()==y and x^xx) v[x^xx-1]^=1; return vi(begin(v),begin(v)+n);
}

Compilation message

transfer.cpp: In function 'vi get_attachment(vi)':
transfer.cpp:8:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for(int i = 0; i < sz(v); i++) if(v[i]) x^=i+1;
      |                   ^
transfer.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
    9 |  for(int i = 0; i < __lg(sz(v)+1); i++) a.push_back((x>>i)&1), y^=(x>>i)&1;
      |                 ~~^~~~~~~~~~~~~~~
transfer.cpp: In function 'vi retrieve(vi)':
transfer.cpp:17:33: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   17 |  if(v.back()==y and x^xx) v[x^xx-1]^=1; return vi(begin(v),begin(v)+n);
      |                               ~~^~
transfer.cpp:17:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   17 |  if(v.back()==y and x^xx) v[x^xx-1]^=1; return vi(begin(v),begin(v)+n);
      |  ^~
transfer.cpp:17:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   17 |  if(v.back()==y and x^xx) v[x^xx-1]^=1; return vi(begin(v),begin(v)+n);
      |                                         ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 640 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2496 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -