제출 #697285

#제출 시각아이디문제언어결과실행 시간메모리
697285BaytoroArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; #define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define endl '\n' #define ll long long #define int long long void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } const int N=1e6+5; int bit[N]; void update(int i, int v){ for(;i<=N;i+=i&-i){ bit[i]+=v; } } int query(int i){ int res=0; for(;i>0;i-=i&-i) res+=bit[i]; return res; } int query(int l, int r){ return query(r)-query(l-1); } vector<int> a[N][2]; int count_swaps(vector<int> s){ int n=s.size(); for(int i=1;i<=n;i++){ update(i,1); a[abs(s[i-1])][s[i-1]<0].pb(i); } int res=0; for(int i=1;i<=n;i++) for(int j=0;j<2;j++) reverse(all(a[i][j])); for(int i=1;i<=n;i++){ if(!s[i-1]) continue; int x=s[i-1],y=(s[i-1]<0),z=a[abs(x)][y^1].back(); a[abs(x)][0].pop_back(); a[abs(x)][1].pop_back(); s[z-1]=0; s[i-1]=0; update(z,-1); if(y) res+=query(i+1,z); else res+=query(i,z); } return res; } /*void solve(){ int n;cin>>n; vector<int> vec(n); for(int i=0;i<n;i++) cin>>vec[i]; cout<<count_swaps(vec); } main(){ ios; int T=1; //cin>>T; while(T--){ solve(); } }*/

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

shoes.cpp: In function 'void fopn(std::string)':
shoes.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen((name+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shoes.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen((name+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccmCUd8X.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