Submission #252283

#TimeUsernameProblemLanguageResultExecution timeMemory
252283HeheheSorting (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], m; pair<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; }

Compilation message (stderr)

sorting.cpp: In function 'bool check(ll, ll*)':
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: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
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:5:12: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
 #define ff first
            ^
sorting.cpp:94:23: note: in expansion of macro 'ff'
         P[i] = ans[i].ff;
                       ^~
sorting.cpp:6:12: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
 #define ss second
            ^
sorting.cpp:95:23: note: in expansion of macro 'ss'
         Q[i] = ans[i].ss;
                       ^~
sorting.cpp:98:12: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
     return m;
            ^