제출 #233224

#제출 시각아이디문제언어결과실행 시간메모리
233224FieryPhoenix정렬하기 (IOI15_sorting)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "sorting.h" using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; typedef long double ld; #define INF 2001001001 #define MOD 1000000007 int N,S[200001]; int M,X[600001],Y[600001]; int arr[200001]; bool vis[200001]; int to[200001]; deque<pair<int,int>>q; int pos[200001]; void dfs(int node){ vis[node]=true; if (!vis[arr[node]]){ q.push_back({node,arr[node]}); dfs(arr[node]); //cout<<"Q: "<<arr[node]<<' '<<arr[to[node]]<<endl; } } bool check(int mid){ q.clear(); for (int i=0;i<N;i++){ arr[i]=S[i]; vis[i]=false; } for (int i=1;i<=mid;i++) swap(arr[X[i]],arr[Y[i]]); int comps=0; for (int i=0;i<N;i++){ pos[arr[i]]=i; if (!vis[arr[i]]){ comps++; q.push_back({i,arr[i]}); dfs(arr[i]); q.pop_back(); } } return N-comps<=mid; } int findSwapPairs(int n,int s[],int m, int x[], int y[],int P[], int Q[]){ N=n; for (int i=0;i<N;i++) S[i]=s[i]; M=m; for (int i=1;i<=M;i++){ X[i]=x[i]; Y[i]=y[i]; } for (int high=0;high<=M;high++){ check(high); for (int i=high;i>=1;i--){ if (!q.empty()){ P[i]=pos[q[0].first]; Q[i]=pos[q[0].second]; swap(pos[arr[X[i]]],pos[arr[Y[i]]]); swap(arr[X[i]],arr[Y[i]]); q.pop_front(); } } for (int i=0;i<N;i++) arr[i]=S[i]; for (int i=1;i<=high;i++){ swap(arr[X[i]],arr[Y[i]]); swap(arr[P[i]],arr[Q[i]]); } bool good=true; for (int i=0;i<N;i++) if (S[i]!=i) good=false; if (good) break; } return high; }

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

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:80:10: error: 'high' was not declared in this scope
   return high;
          ^~~~
sorting.cpp:80:10: note: suggested alternative: 'sinh'
   return high;
          ^~~~
          sinh