Submission #213572

#TimeUsernameProblemLanguageResultExecution timeMemory
213572_Ice_Tea_Data Transfer (IOI19_transfer)C++14
92 / 100
348 ms2976 KiB
#include<bits/stdc++.h> #include "transfer.h" #define de(x) if( x && x == MODE) #define MODE 0 using namespace std; std::vector<int> get_attachment(std::vector<int> source) { int i,j,k; int N = source.size(); int L = ( N == 63 ? 6 : 9 ); // int L = 3; vector<int> attach; for( i=0; i<L; i++) { int key = 0; for( j=0; j<N; j++) { if( (j>>i)&1 ) continue; key ^= source[j]; } attach.push_back(key); } int key = 0; for( auto it:attach) key ^= it; attach.push_back(key); de(1) { printf(">>> "); for( auto it:attach) printf("%d ", it); printf("\n"); } return attach; } std::vector<int> retrieve(std::vector<int> data) { int i,j; int N = ( data.size() == 70 ? 63 : 255); // int N = 7; int L = data.size() - N - 1; vector<int> ans; int arr[256]; int idx = 0; for( i=0; i<L; i++) { int key = 0; for( j=0; j<N; j++) { if( (j>>i)&1 ) continue; key ^= data[j]; } if( key == data[ N+i ]) idx ^= (1<<i); } de(1) printf("idx = %d\n", idx); for( i=0; i<N; i++) ans.push_back( data[i] ); if( idx == N) { // return ans; } else { int key = 0; for( i=0; i<L; i++) key ^= data[ N+i ]; if( key != data.back()) { // return ans; } else { ans[idx] ^= 1; // return ans; } } de(1) { printf("ans = "); for( auto it: ans) printf("%d", it); printf("\n"); } return ans; }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:11:10: warning: unused variable 'k' [-Wunused-variable]
  int i,j,k;
          ^
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:54:6: warning: unused variable 'arr' [-Wunused-variable]
  int arr[256];
      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...