제출 #1195155

#제출 시각아이디문제언어결과실행 시간메모리
1195155nikulidSorting (IOI15_sorting)C++20
컴파일 에러
0 ms0 KiB
#include "sorting.h" #include <vector> using namespace std; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { // we are given S[], M, X[], Y[] // we are to give P[], Q[] vector<int> ns; for(int i=0; i<N; i++){ ns.push_back(S[i]); } for(int i=0; i<N; i++){ P[i] = i; Q[i] = ns[i]; swap(ns[i], ns[ns[i]]); already_sorted=true; for(int j=1; j<N; j++){ if(ns[j-1] > ns[j]){ already_sorted=false; break; } } if(already_sorted){ return i+1; } } return N; } // 3 2 5 1 4 // -op1 // 1 2 5 3 4 // -op2 // 1 2 5 3 4 // -op3 // 1 2 3 5 4 // -op4 // 1 2 3 4 5 // -op5 //

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

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:17:9: error: 'already_sorted' was not declared in this scope
   17 |         already_sorted=true;
      |         ^~~~~~~~~~~~~~