제출 #168973

#제출 시각아이디문제언어결과실행 시간메모리
168973pulpy_orangeArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long ll count_swaps(vector<ll>S){ n=S.size(); ll vis[n]; memset(vis, 0, sizeof(vis)); for(ll i=0;i<n;i++){ if(vis[i])continue; ll curr=S[i]; vis[i]=1; if(curr<0){ for(ll j=i+1;j<n;j++){ if(!vis[j] and S[j]>0 and curr==-1*S[j]){ vis[j]=1; ans+=(j-1-i); break; } } } else{ for(ll j=i+1;j<n;j++){ if(!vis[j] and S[j]<0 and curr==-1*S[j]){ vis[j]=1; ans+=(j-i); break; } } } } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<long long int>)':
shoes.cpp:6:6: error: 'n' was not declared in this scope
      n=S.size();
      ^
shoes.cpp:8:13: error: 'vis' was not declared in this scope
      memset(vis, 0, sizeof(vis));
             ^~~
shoes.cpp:18:26: error: 'ans' was not declared in this scope
                          ans+=(j-1-i);
                          ^~~
shoes.cpp:18:26: note: suggested alternative: 'abs'
                          ans+=(j-1-i);
                          ^~~
                          abs
shoes.cpp:27:26: error: 'ans' was not declared in this scope
                          ans+=(j-i);
                          ^~~
shoes.cpp:27:26: note: suggested alternative: 'abs'
                          ans+=(j-i);
                          ^~~
                          abs
shoes.cpp:33:13: error: 'ans' was not declared in this scope
      return ans;
             ^~~
shoes.cpp:33:13: note: suggested alternative: 'abs'
      return ans;
             ^~~
             abs