제출 #143914

#제출 시각아이디문제언어결과실행 시간메모리
143914NucleistArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "shoes.h" 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int count_swaps(vector<int>gg)
{
  //flash;
  int ans=0;
  int index=0;
  for (int i = 0; i < n; i+=2)
  {
    for (int j = i; j < n; ++j)
    {
      if(gg[j]<0)
      {
        //debugs(j,i);
        int newi=j;
        while(gg[i]>0)
        {
          int k = gg[newi-1];
          gg[newi-1]=gg[newi];
          gg[newi]=k;
          newi--;
          ans++;
        }
        break;
      }
    }
    for (int j = i+1; j < n; ++j)
    {
      if(gg[j]==(-gg[i]))
      {
        int nexi=j;
        while(gg[i+1]!=(-gg[i]))
        {
          int k = gg[nexi-1];
          gg[nexi-1]=gg[nexi];
          gg[nexi]=k;
          nexi--;
          ans++;
        }
        break;  
      }
    }
  }
  return ans;
}
//code the AC sol !
// BS/queue/map

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

shoes.cpp: In function 'int count_swaps(std::vector<int>)':
shoes.cpp:17:5: error: ambiguating new declaration of 'int count_swaps(std::vector<int>)'
 int count_swaps(vector<int>gg)
     ^~~~~~~~~~~
In file included from shoes.cpp:2:0:
shoes.h:7:11: note: old declaration 'long long int count_swaps(std::vector<int>)'
 long long count_swaps(std::vector<int> S);
           ^~~~~~~~~~~
shoes.cpp:22:23: error: 'n' was not declared in this scope
   for (int i = 0; i < n; i+=2)
                       ^
shoes.cpp:21:7: warning: unused variable 'index' [-Wunused-variable]
   int index=0;
       ^~~~~