제출 #316784

#제출 시각아이디문제언어결과실행 시간메모리
316784Tahmid690Arranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> //#include "shoes.h" using namespace std; long long count_swaps(vector<int> ara){ int flag=0; for(int i=1;i<ara.size();i++) if(abs(ara[i])!=abs(ara[i-1])) flag=1; if(flag==0){ long long ans=0; long long m,x=0; m=ara.size()/2; for(int i=0;i<ara.size();i++){ if(ara[i]<0){ if(i%2==1) ans++; } } return ans; } long long n; n=ara.size(); n/=2; if(n==1){ if(ara[0]<0) return 0; else return 1; } return (n*(n-1))/2; } int main(){ int n; cin >> n; vector<int> vct; while(n--){ int x; cin >> x; vct.push_back(x); } cout << count_swaps(vct) << endl; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:6:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |     for(int i=1;i<ara.size();i++) if(abs(ara[i])!=abs(ara[i-1])) flag=1;
      |                 ~^~~~~~~~~~~
shoes.cpp:11:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |         for(int i=0;i<ara.size();i++){
      |                     ~^~~~~~~~~~~
shoes.cpp:9:19: warning: variable 'm' set but not used [-Wunused-but-set-variable]
    9 |         long long m,x=0;
      |                   ^
shoes.cpp:9:21: warning: unused variable 'x' [-Wunused-variable]
    9 |         long long m,x=0;
      |                     ^
/tmp/ccTiqktZ.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc1zKncI.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status