제출 #786455

#제출 시각아이디문제언어결과실행 시간메모리
786455LIFAliens (IOI16_aliens)C++14
16 / 100
92 ms2380 KiB
#include "aliens.h" #include<bits/stdc++.h> #include<vector> using namespace std; int rr[300005]; int cc[300005]; int color[305][305]; int dp[1005][1005]; struct node { int r; int c; }nod[500005]; bool cmp(node x,node y) { return x.r < y.r; } long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { for(int i=0;i<r.size();i++)rr[i+1] = r[i]; for(int i=0;i<c.size();i++)cc[i+1] = c[i]; bool flag2 = true; for(int i=1;i<=n;i++) { if(rr[i] > cc[i])swap(rr[i],cc[i]); if(rr[i] != cc[i])flag2 = false; } for(int i=1;i<=n;i++) { for(int j=1;j<=k;j++)dp[i][j] = 1e9; dp[i][0] = 1e9; } dp[0][0] = 0; if(k == n && m <= 100) { for(int i=1;i<=n;i++) { for(int j=min(rr[i],cc[i]);j<=max(rr[i],cc[i]);j++) { for(int k=min(rr[i],cc[i]);k<=max(rr[i],cc[i]);k++)color[j][k] = 1; } } int cnt = 0; for(int i=0;i<=m-1;i++) { for(int j=0;j<=m-1;j++)if(color[i][j] == 1)cnt++; } return cnt; } if(flag2 == true) { for(int i=1;i<=n;i++) { nod[i].r = rr[i]; nod[i].c = cc[i]; } sort(nod+1,nod+n+1,cmp); nod[0].r = 0; nod[0].c = 0; for(int i=1;i<=n;i++) { for(int j=1;j<=k;j++) { for(int pre=0;pre<=i-1;pre++) { dp[i][j] = min(dp[i][j],dp[pre][j-1] + (nod[i].r-nod[pre+1].r + 1) * (nod[i].r-nod[pre+1].r + 1)); } // dp[i][j] = min(dp[i][j],dp[i-1][j-1] + 1); } } int ans = 1e9; for(int i=1;i<=k;i++) { ans = min(ans,dp[n][i]); } return ans; } return 0; }

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

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:19:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  for(int i=0;i<r.size();i++)rr[i+1] = r[i];
      |              ~^~~~~~~~~
aliens.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(int i=0;i<c.size();i++)cc[i+1] = c[i];
      |              ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...