제출 #170530

#제출 시각아이디문제언어결과실행 시간메모리
170530SwanBali Sculptures (APIO15_sculpture)C++14
46 / 100
1077 ms6296 KiB
#include <bits/stdc++.h> #define stop system("pause") #define stop2 char o; cin >> o #define INP freopen("pcb.in","r",stdin) #define OUTP freopen ("pcb.out","w",stdout) #define int long long using namespace std; const int maxn = 210; set<int> dp[maxn][maxn]; int ans[maxn][maxn]; set<int> ::iterator it; bool prosev(int x,int y,int need){ vector<int> bad; for(it = dp[x][y].begin();it!=dp[x][y].end();it++){ if(*it == need)return 0; int a = need^(need|(*it)); int b = (*it)^((*it)|need); if(!a){ return 0; } if(!b){ bad.push_back(*it); } } for(int i(0); i < bad.size();i++){ dp[x][y].erase(dp[x][y].find(bad[i])); } return 1; } main(){ ios_base::sync_with_stdio(0); int n,a,b; cin >> n >> a >> b; vector<int> v; v.push_back(0); //srand(time(0)); for(int i(1); i <= n;i++){ int x;cin>>x; v.push_back(x); } dp[0][0].insert(0); for(int i(0);i<=n;i++){ for(int j(0);j<=n;j++){ ans[i][j] = 1e16; } } for(int k(1);k<=b;k++){ for(int i(1); i <=n;i++){ int sum = 0; //cout << k << ' ' << i << ' ' << ans[k][i] << endl; for(int to(i);to > 0;to--){ sum+=v[to]; for(auto&a : dp[k-1][to-1]){ bool f = prosev(k,i,sum|a); if(f)dp[k][i].insert(sum|a); ans[k][i] = min(ans[k][i],(sum|a)); } } //cout << k << ' ' << i << ' ' << ans[k][i] << endl; //prosev(k,i); } } int res = 1e17; for(int i(a);i<=b;i++){ //cout << i << ' ' << ans[i][n] << endl; res = min(res,ans[i][n]); } cout << res; } /* 6 1 3 8 1 2 1 5 4 100 1 100 5 1 5 5 4 3 2 1 */

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

sculpture.cpp: In function 'bool prosev(long long int, long long int, long long int)':
sculpture.cpp:28:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i(0); i < bad.size();i++){
                   ~~^~~~~~~~~~~~
sculpture.cpp: At global scope:
sculpture.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#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...