제출 #972398

#제출 시각아이디문제언어결과실행 시간메모리
972398MarwenElarbiAliens (IOI16_aliens)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define ll long long const int nax=50005; vector<pair<long long,long long>> v; long long dp[50005][1005]; bool compare(pair<int,int> a,pair<int,int> b){ if(a.fi!=b.fi) return a.fi<b.fi; return a.se>b.se; } void daq(int l,int r,int left,int right,int level){ if(l>r) return; int mid=(r+l)/2; //if(dp[mid][level]<1e18) return; ll opt=0; ll lst=v[mid].se; ll cur=1; //cout <<l<<" "<<r<<" "<<left<<" "<<right<<" "<<mid<<endl; for (int i = min(right,mid); i >= left; --i) { if(i==0){ dp[mid][1]=cur*cur; continue; } cur+=lst-v[i].fi; lst=v[i].fi; long long nabba=dp[i-1][level-1]+cur*cur-1ll*max(1ll*0,v[i-1].se-v[i].fi+1)*max(1ll*0,v[i-1].se-v[i].fi+1); if(dp[mid][level]>nabba){ opt=i; dp[mid][level]=nabba; } //cout <<mid<<" "<<i<<" "<<nabba<<" "<<dp[i-1][level-1]<<" "<<level<<endl; } //cout <<dp[mid][level]<<" "<<opt<<endl; if(l==r) return; daq(l,mid,left,opt,level); daq(mid+1,r,opt,right,level); } long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c){ pair<int,int> tab[n]; for (int i = 0; i < n; ++i) { tab[i]={min(r[i],c[i]),max(r[i],c[i])}; } sort(tab,tab+n,compare); v.push_back({-1,-1}); for (int i = 0; i < n; ++i) { if(v.empty()) v.push_back(tab[i]); else if(v.back().se>=tab[i].se) continue; else v.push_back(tab[i]); } n=v.size(); for (int i = 0; i < n; ++i) { for (int j = 0; j <= k; ++j) { if(i) dp[i][j]=2e18; else dp[i][j]=0; } } for (int i = 1; i <= k; ++i) { daq(1,n-1,1,n-1,i); } long long ans=1ll*m*m; for (int i = 1; i <= k; ++i) { ans=min(ans,dp[n-1][i]); } return ans; } int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, m, k; assert(3 == scanf("%d %d %d", &n, &m, &k)); std::vector<int> r(n), c(n); for (int i = 0; i < n; i++) { assert(2 == scanf("%d %d", &r[i], &c[i])); } long long ans = take_photos(n, m, k, r, c); printf("%lld\n", ans); return 0; }

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

aliens.cpp: In function 'int main()':
aliens.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:78:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccy18Ba5.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccIYzbG8.o:aliens.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status