Submission #782014

# Submission time Handle Problem Language Result Execution time Memory
782014 2023-07-13T14:45:34 Z Dan4Life Data Transfer (IOI19_transfer) C++17
100 / 100
59 ms 2588 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: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:44: 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);
      |                                            ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 684 KB Output is correct
2 Correct 3 ms 732 KB Output is correct
3 Correct 2 ms 644 KB Output is correct
4 Correct 2 ms 728 KB Output is correct
5 Correct 3 ms 668 KB Output is correct
6 Correct 2 ms 644 KB Output is correct
7 Correct 2 ms 748 KB Output is correct
8 Correct 2 ms 644 KB Output is correct
9 Correct 2 ms 644 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 2 ms 696 KB Output is correct
12 Correct 2 ms 736 KB Output is correct
13 Correct 2 ms 728 KB Output is correct
14 Correct 3 ms 624 KB Output is correct
15 Correct 3 ms 704 KB Output is correct
16 Correct 3 ms 644 KB Output is correct
17 Correct 3 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 2484 KB Output is correct
2 Correct 35 ms 2448 KB Output is correct
3 Correct 54 ms 2540 KB Output is correct
4 Correct 59 ms 2488 KB Output is correct
5 Correct 54 ms 2492 KB Output is correct
6 Correct 59 ms 2488 KB Output is correct
7 Correct 42 ms 2492 KB Output is correct
8 Correct 36 ms 2488 KB Output is correct
9 Correct 31 ms 2488 KB Output is correct
10 Correct 33 ms 2588 KB Output is correct
11 Correct 48 ms 2488 KB Output is correct
12 Correct 50 ms 2488 KB Output is correct
13 Correct 33 ms 2488 KB Output is correct
14 Correct 39 ms 2452 KB Output is correct
15 Correct 49 ms 2488 KB Output is correct
16 Correct 37 ms 2452 KB Output is correct
17 Correct 40 ms 2488 KB Output is correct
18 Correct 48 ms 2488 KB Output is correct
19 Correct 51 ms 2488 KB Output is correct