Submission #252279

#TimeUsernameProblemLanguageResultExecution timeMemory
252279HeheheSorting (IOI15_sorting)C++14
Compilation error
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]; paie<ll, ll>query[H], ans[H]; bool check(ll t, ll S[]){ int 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; int 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 int 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[]) { int 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; }

Compilation message (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:45:22: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
         int v = out[i];
                 ~~~~~^
sorting.cpp:48:22: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
             v = out[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:17: error: 'query' was not declared in this scope
         int 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:84:9: warning: declaration of 'n' shadows a global declaration [-Wshadow]
     int n = N, m = M;
         ^
sorting.cpp:22:12: note: shadowed declaration is here
 ll pos[H], n, in[H], out[H];
            ^
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