제출 #994313

#제출 시각아이디문제언어결과실행 시간메모리
994313cpdreamerArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <utility> using namespace __gnu_pbds; using namespace std; typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set; const int max_n=INT_MAX; typedef long long ll; #define LLM LONG_LONG_MAX #define pb push_back #define F first #define L length() #define all(v) v.begin(),v.end() #define P pair #define V vector #define S second const long long MOD = 1000000007; // 1e9 + 7 void file(){ freopen("input.txt.txt","r",stdin); freopen("output.txt.txt","w",stdout); } void setio(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } long long count_swaps(vector<int> s) { int n=(int)s.size(); long long c=0; for(int i=0;i<n-1;i++){ if(i%2==0){ if(s[i]<0) continue; int index; for(int j=i+1;j<n;j++){ if(s[j]<0){ index=j; break; } } for(int j=index;j>i;j--){ swap(s[j],s[j-1]); c++; } } else{ if(s[i]==-s[i-1]) continue; int index; for(int j=i+1;j<n;j++){ if(s[j]==-s[i-1]){ index=j; break; } } for(int j=index;j>i;j--){ swap(s[j],s[j-1]); c++; } } } return c; } void solve() { int n; cin>>n; V<int>s(2*n); for(int i=0;i<2*n;i++) cin>>s[i]; cout<<count_swaps(s)<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //file(); solve(); return 0; }

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

shoes.cpp: In function 'void file()':
shoes.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen("input.txt.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
shoes.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen("output.txt.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shoes.cpp: In function 'void setio(std::string)':
shoes.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shoes.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:59:25: warning: 'index' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |                 swap(s[j],s[j-1]);
      |                         ^
shoes.cpp:44:25: warning: 'index' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |                 swap(s[j],s[j-1]);
      |                         ^
/usr/bin/ld: /tmp/ccAomU0y.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccPyLnsz.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status