Submission #421370

# Submission time Handle Problem Language Result Execution time Memory
421370 2021-06-09T05:54:53 Z Andyvanh1 Data Transfer (IOI19_transfer) C++14
Compilation error
0 ms 0 KB
#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;
 
bool jump(int x){
    cout<<x<<endl;
    bool ans;
    cin>>ans;
    return ans;
}
 
vi get_attachment(vi source){
    vi ans(12);
    vi x = 0;
    int ct = 0;
    for(int i = 1; i <= 63; i++){
        x^=i*(source[i-1]);
        if(source[i-1])ct++;
    }
    for(int i = 0; i < 6; i++){
        ans[i] = ((1<<i)&x ? 1 : 0);
        if(ans[i])ct++;
    }
    for(int i = 0; i < 6; i++){
        ans[i+6] = ((1<<i)&ct?1:0);
    }
    return ans;
}
 
vi retrieve_data(vi data){
    int x = 0;
    vi ans1(63);
    vi ans2(6);
    vi ans3(6);
    for(int i = 0; i < 63; i++){
        ans1[i] = data[i];
    }
    for(int i = 63; i < 69; i++){
        ans2[i-63] = data[i];
    }
    for(int i = 69; i < 75; i++){
        ans3[i-69] = data[i];
    }
    int x = 0;
    int y = 0;
    int z = 0;
    int ct = 0;
    for(int i = 1; i <= 63; i++){
        x^=i*(ans1[i-1]);
        if(ans1[i-1])ct++;
    }
    for(int i = 0; i < 6; i++){
        y+=(1<<i)*ans2[i];
        z+=(1<<i)*ans3[i];
        if(ans2[i])ct++;
    }
    if(x==y)return ans1;
    if(ct>z){
        if(x<y){
            ans1[x^y-1]^=1;
            return ans1;
        }else{
            return ans1;
        }
    }else{
        if(x>y){
            ans1[x^y-1]^=1;
            return ans1;
        }else{
            return ans1;
        }
    }
 
}

Compilation message

transfer.cpp: In function 'bool jump(int)':
transfer.cpp:18:5: error: 'cout' was not declared in this scope
   18 |     cout<<x<<endl;
      |     ^~~~
transfer.cpp:2:1: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    1 | #include "transfer.h"
  +++ |+#include <iostream>
    2 | 
transfer.cpp:18:14: error: 'endl' was not declared in this scope
   18 |     cout<<x<<endl;
      |              ^~~~
transfer.cpp:2:1: note: 'std::endl' is defined in header '<ostream>'; did you forget to '#include <ostream>'?
    1 | #include "transfer.h"
  +++ |+#include <ostream>
    2 | 
transfer.cpp:20:5: error: 'cin' was not declared in this scope
   20 |     cin>>ans;
      |     ^~~
transfer.cpp:20:5: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
transfer.cpp: In function 'vi get_attachment(vi)':
transfer.cpp:26:12: error: conversion from 'int' to non-scalar type 'vi' {aka 'std::vector<int>'} requested
   26 |     vi x = 0;
      |            ^
transfer.cpp:29:10: error: no match for 'operator^=' (operand types are 'vi' {aka 'std::vector<int>'} and 'int')
   29 |         x^=i*(source[i-1]);
transfer.cpp:33:25: error: no match for 'operator&' (operand types are 'int' and 'vi' {aka 'std::vector<int>'})
   33 |         ans[i] = ((1<<i)&x ? 1 : 0);
      |                   ~~~~~~^~
      |                     |    |
      |                     int  vi {aka std::vector<int>}
transfer.cpp: In function 'vi retrieve_data(vi)':
transfer.cpp:56:9: error: redeclaration of 'int x'
   56 |     int x = 0;
      |         ^
transfer.cpp:43:9: note: 'int x' previously declared here
   43 |     int x = 0;
      |         ^
transfer.cpp:72:21: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   72 |             ans1[x^y-1]^=1;
      |                    ~^~
transfer.cpp:79:21: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   79 |             ans1[x^y-1]^=1;
      |                    ~^~