제출 #252282

#제출 시각아이디문제언어결과실행 시간메모리
252282Hehehe정렬하기 (IOI15_sorting)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> //:3
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define pi pair <int, int>
#define sz(x) (int)((x).size())
#include "sorting.h"

const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

const ll H = 1e6 + 11;

//ifstream in(".in");
//ofstream out(".out");

ll pos[H], n, in[H], out[H], m;
paie<ll, ll>query[H], ans[H];

bool check(ll t, ll S[]){
    ll k = 0;

    for(int i = 0; i < n; i++){
        in[i] = out[i] = S[i];
    }

    for(int i = 0; i < t; i++){
        swap(out[query[i].ff], out[query[i].ss]);
    }

    bool viz[n + 11];
    memset(viz, 0, sizeof(viz));

    for(int i = 0; i < n; i++){

        if(viz[i])continue;

        vector<int>cur;

        ll v = out[i];
        while(v != i){
            cur.push_back(v);
            v = out[v];
        }
        cur.push_back(v);

        for(int j = sz(cur) - 1; j > 0; j--){
            ans[k++] = {cur[0], cur[j]};
        }

        for(auto it : cur)viz[it] = 1;
    }

    if(k > t)return 0;

    for(int i = 0; i < k; i++){

        //His move
        ll x = query[i].ff, y = query[i].ss;
        swap(in[x], in[y]);
        pos[in[x]] = x;
        pos[in[y]] = y;

        //My move
        x = ans[i].ff, y = ans[i].ss;
        swap(in[x], in[y]);
        pos[in[x]] = x;
        pos[in[y]] = y;
    }

    while(k < t)ans[k++] = {0, 0};

    return 1;

}

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {

    n = N; m = M;

    for(int i = 0; i < n; i++){
        query[i].ff = X[i];
        query[i].ss = Y[i];
    }

    check(m, S);

    for(int i = 0; i < m; i++){
        P[i] = ans[i].ff;
        Q[i] = ans[i].ss;
    }

    return m;
}

컴파일 시 표준 에러 (stderr) 메시지

sorting.cpp:23:1: error: 'paie' does not name a type; did you mean 'raise'?
 paie<ll, ll>query[H], ans[H];
 ^~~~
 raise
sorting.cpp: In function 'bool check(ll, ll*)':
sorting.cpp:33:18: error: 'query' was not declared in this scope
         swap(out[query[i].ff], out[query[i].ss]);
                  ^~~~~
sorting.cpp:47:28: warning: conversion to 'std::vector<int>::value_type {aka int}' from 'll {aka long long int}' may alter its value [-Wconversion]
             cur.push_back(v);
                            ^
sorting.cpp:50:24: warning: conversion to 'std::vector<int>::value_type {aka int}' from 'll {aka long long int}' may alter its value [-Wconversion]
         cur.push_back(v);
                        ^
sorting.cpp:53:13: error: 'ans' was not declared in this scope
             ans[k++] = {cur[0], cur[j]};
             ^~~
sorting.cpp:53:13: note: suggested alternative: 'abs'
             ans[k++] = {cur[0], cur[j]};
             ^~~
             abs
sorting.cpp:64:16: error: 'query' was not declared in this scope
         ll x = query[i].ff, y = query[i].ss;
                ^~~~~
sorting.cpp:65:24: error: 'y' was not declared in this scope
         swap(in[x], in[y]);
                        ^
sorting.cpp:70:13: error: 'ans' was not declared in this scope
         x = ans[i].ff, y = ans[i].ss;
             ^~~
sorting.cpp:70:13: note: suggested alternative: 'abs'
         x = ans[i].ff, y = ans[i].ss;
             ^~~
             abs
sorting.cpp:76:17: error: 'ans' was not declared in this scope
     while(k < t)ans[k++] = {0, 0};
                 ^~~
sorting.cpp:76:17: note: suggested alternative: 'abs'
     while(k < t)ans[k++] = {0, 0};
                 ^~~
                 abs
sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:87:9: error: 'query' was not declared in this scope
         query[i].ff = X[i];
         ^~~~~
sorting.cpp:91:15: error: cannot convert 'int*' to 'll* {aka long long int*}' for argument '2' to 'bool check(ll, ll*)'
     check(m, S);
               ^
sorting.cpp:94:16: error: 'ans' was not declared in this scope
         P[i] = ans[i].ff;
                ^~~
sorting.cpp:94:16: note: suggested alternative: 'abs'
         P[i] = ans[i].ff;
                ^~~
                abs
sorting.cpp:98:12: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
     return m;
            ^