제출 #832208

#제출 시각아이디문제언어결과실행 시간메모리
832208kebineArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
#define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define tup tuple<int, int, int>
#define pii pair<int, int>
#define fi first
#define se second
#define pub push_back
#define pob pop_back
int count_swaps(vector<int> s) {
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 0) continue;
        if(s[i] < 0) {
            int cnt = 0;
            for(int j = i+1; j < s.size(); j++) {
                if(s[j] == 0) {
                    cnt++;
                    continue;
                }

                if(s[j] == -s[i]) {
                    ans += j-i-1 - cnt;
                    s[i] = s[j] = 0;
                    break;
                }
            }
        }
        else {
            int cnt = 0;
            for(int j = i+1; j < s.size(); j++) {
                if(s[j] == 0) {
                    cnt++;
                    continue;
                }

                if(s[j] == -s[i]) {
                    ans += j-i - cnt;
                    s[i] = s[j] = 0;
                    break;
                }
            }
        }
    }
    return ans;
}

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

shoes.cpp: In function 'long long int count_swaps(std::vector<long long int>)':
shoes.cpp:13:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i = 0; i < s.size(); i++) {
      |                    ~~^~~~~~~~~~
shoes.cpp:17:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |             for(int j = i+1; j < s.size(); j++) {
      |                              ~~^~~~~~~~~~
shoes.cpp:32:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             for(int j = i+1; j < s.size(); j++) {
      |                              ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccsin58r.o: in function `main':
grader.cpp:(.text.startup+0x2a8): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status