Submission #421379

# Submission time Handle Problem Language Result Execution time Memory
421379 2021-06-09T06:06:48 Z Andyvanh1 Data Transfer (IOI19_transfer) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "transfer.h"
 
using namespace std;
 
#define vt vector
#define INF 0x3f3f3f3f
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for(int (i) = 0;(i) < (x); (i)++)
#define MOD 1000000007
 
typedef vt<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
 
 
vi get_attachment(vi source){
    vi ans(7);
    int x = 0;
    int ct = 0;
    for(int i = 1; i <= 63; i++){
        x^=i*(source[i-1]);
 
    }
    for(int i = 0; i < 6; i++){
        ans[i] = ((1<<i)&x ? 1 : 0);
        if(ans[i])ct++;
    }
    ans[6] = ct&1;
    return ans;
}
 
vi retrieve_data(vi data){
 
    vi ans1(63);
    vi ans2(6);
    int ans3;
    for(int i = 0; i < 63; i++){
        ans1[i] = data[i];
    }
    for(int i = 63; i < 69; i++){
        ans2[i-63] = data[i];
    }
    ans3 = data[69];
    int x = 0;
    int y = 0;
    int z = 0;
    int ct = 0;
    for(int i = 1; i <= 63; i++){
        x^=i*(ans1[i-1]);
 
    }
    for(int i = 0; i < 6; i++){
        y+=(1<<i)*ans2[i];
 
 
    }
    if(x==y)return ans1;
    if(y&1!=ans3){
        return ans1;
    }else{
        ans1[x^y-1]^=1;
        return ans1;
    }
 
}

Compilation message

transfer.cpp: In function 'vi retrieve_data(vi)':
transfer.cpp:61:11: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   61 |     if(y&1!=ans3){
      |          ~^~~~~~
transfer.cpp:64:17: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   64 |         ans1[x^y-1]^=1;
      |                ~^~
transfer.cpp:49:9: warning: unused variable 'z' [-Wunused-variable]
   49 |     int z = 0;
      |         ^
transfer.cpp:50:9: warning: unused variable 'ct' [-Wunused-variable]
   50 |     int ct = 0;
      |         ^~
/usr/bin/ld: /tmp/cc5bGVBT.o: in function `pass2()':
grader.cpp:(.text+0x1711): undefined reference to `retrieve(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status