제출 #421259

#제출 시각아이디문제언어결과실행 시간메모리
421259Pbezz정렬하기 (IOI15_sorting)C++14
컴파일 에러
0 ms0 KiB
for(i=2;i<N;i++){//find i, send it to ith position

for(k=0;k<N;k++){
if(S[k]==i)break;
}
if(k!=i){
P[R]=k;
Q[R]=i;
R++;
swap(S[k],S[i]);
	ok=true;
	for(j=0;j<N;j++){
	if(S[j]!=j)ok=false;
	}
	if(ok){
	return R;
	}
swap(S[0],S[1]);
}

}

if(S[0]==1){
P[R]=0;
Q[R]=0;
R++;
}

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

sorting.cpp:1:1: error: expected unqualified-id before 'for'
    1 | for(i=2;i<N;i++){//find i, send it to ith position
      | ^~~
sorting.cpp:1:9: error: 'i' does not name a type
    1 | for(i=2;i<N;i++){//find i, send it to ith position
      |         ^
sorting.cpp:1:13: error: 'i' does not name a type
    1 | for(i=2;i<N;i++){//find i, send it to ith position
      |             ^
sorting.cpp:23:1: error: expected unqualified-id before 'if'
   23 | if(S[0]==1){
      | ^~