제출 #1165837

#제출 시각아이디문제언어결과실행 시간메모리
1165837SG2AlokArranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
long long ans = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] < 0){
			int pos = -1;
			for(int j = i + 1; j < s.size(); j++){
				if(s[j] == -s[i]){
					pos = j;
					break;
				}
			}
			
			while(pos > i + 1){
				swap(s[pos], s[pos - 1]);
				pos--;
				ans++;
			}
			
			i++;
		} else if(s[i] > 0){
			int pos = -1;
			for(int j = i + 1; j < s.size(); j++){
				if(s[j] == -s[i]){
					pos = j;
					break;
				}
			}
			
			while(pos > i){
				swap(s[pos], s[pos - 1]);
				pos--;
				ans++;
			}
		}
	}
	
	return ans;

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

shoes.cpp:2:9: error: expected unqualified-id before 'for'
    2 |         for(int i = 0; i < s.size(); i++){
      |         ^~~
shoes.cpp:2:28: error: 's' was not declared in this scope
    2 |         for(int i = 0; i < s.size(); i++){
      |                            ^
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:24: error: 'i' does not name a type
    2 |         for(int i = 0; i < s.size(); i++){
      |                        ^
shoes.cpp:2:38: error: 'i' does not name a type
    2 |         for(int i = 0; i < s.size(); i++){
      |                                      ^
shoes.cpp:36:9: error: expected unqualified-id before 'return'
   36 |         return ans;
      |         ^~~~~~