답안 #593235

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
593235 2022-07-10T15:49:14 Z Do_you_copy 비밀 (JOI14_secret) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <secret.h>
#define taskname "test"
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pil = pair <int, ll>;
using pli = pair <ll, int>;
using pll = pair <ll, ll>;
using ull = unsigned ll;
mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count());

ll min(const ll &a, const ll &b){
    return (a < b) ? a : b;
}

ll max(const ll &a, const ll &b){
    return (a > b) ? a : b;
}

//const ll Mod = 1000000009;
//const ll Mod2 = 999999999989;
//only use when required
const int maxN = 1e3 + 1;

int n;
int cal[maxN][maxN];
int a[maxN];
int cnt = 0;
int Secret(int a, int b){
    ++cnt;
    return a ^ b;
}

void prepare(int l = 0, int r = n - 1){
    if (l > r) return;
    int mid = (l + r) / 2;
    cal[mid][mid] = a[mid];
    cal[mid + 1][mid + 1] = a[mid + 1];
    if (l + 1 >= r) return;
    for (int i = mid - 1; i >= l; --i){
        cal[mid][i] = Secret(cal[mid][i + 1], a[i]);
    }
    for (int i = mid + 2; i <= r; ++i){
        cal[mid + 1][i] = Secret(cal[mid + 1][i - 1], a[i]);
    }
    prepare(l, mid - 1);
    prepare(mid + 2, r);
}

int Query(int a, int b){
    int l = 0, r = n - 1;
    while (l < r){
        int mid = (l + r) / 2;
        if (a <= mid && mid + 1 <= b) return Secret(cal[mid][a], cal[mid + 1][b]);
        if (mid == b) return cal[b][a];
        if (mid + 1 == a) return cal[a][b];
        if (b < mid) r = mid - 1;
        if (a > mid + 1) l = mid + 2;
    }
    return cal[l][l];
}

void check(){
    while (1){
        int r = Rand() % n + 1;
        int l = Rand() % r + 1;
        l--; r--;
        cerr << "Comparing l = " << l << " and r = " << r << " ";
        int k = Query(l, r);

        int tem = 0;
        for (int i = l; i <= r; ++i){
            tem ^= a[i];
        }
        if (k != tem){
            cout << "WRONG\n";
            return;
        }
        cout << "CORRECT\n";
    }
}

void Init(int N, int a[]){
    n = N;
    for (int i = 0; i < n; ++i) cin >> a[i];
    prepare();
    //check();
    //eventually asks 6996 times
}


int main(){
    if (fopen(taskname".inp", "r")){
        freopen(taskname".inp", "r", stdin);
        //freopen(taskname".out", "w", stdout);
    }
    faster;
    ll tt = 1;
    //cin >> tt;
    while (tt--){
        Init();
    }
}

Compilation message

secret.cpp: In function 'int main()':
secret.cpp:106:14: error: too few arguments to function 'void Init(int, int*)'
  106 |         Init();
      |              ^
secret.cpp:88:6: note: declared here
   88 | void Init(int N, int a[]){
      |      ^~~~
secret.cpp:99:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   99 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~