제출 #1196678

#제출 시각아이디문제언어결과실행 시간메모리
1196678amanthabandArranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
#include <cmath> #include <iostream> #include <vector> #include <string> #include <algorithm> #include "shoes.h" using namespace std; bool isvalid(vector<int> s){ for (int i = 0; i < s.size() -1; i+=2) { if((s[i+1] == abs(s[i]) ) && s[i] < s[i+1]); return true; } return false; } long long count_swaps(vector<int> s) { int n = s.size(); int cnt = 0; for (int j = 0; j < n; j++) { if (isvalid(s)) { return cnt; } else{ for (int i = 0; i < n-1; i+=2) { if((s[i] != s[i+1] && (s[i+1] != abs(s[i]) || s[i] != abs(s[i+1])) )|| s[i+1] != abs(s[i]) ){ swap(s[i],s[i+1]); cnt++; } if(s[i+1] == abs(s[i] || s[i] == abs(s[i +1])){ if(s[i] < s[i+1]){ continue; } else{ swap(s[i],s[i+1]); cnt++; } } } } } return 0; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:37:59: error: expected ')' before '{' token
   37 |             if(s[i+1] == abs(s[i] || s[i] == abs(s[i +1])){
      |               ~                                           ^
      |                                                           )
shoes.cpp:47:9: error: expected primary-expression before '}' token
   47 |         }
      |         ^