Submission #1062695

#TimeUsernameProblemLanguageResultExecution timeMemory
1062695nvujicaDetecting Molecules (IOI16_molecules)C++14
31 / 100
197 ms2652 KiB
#include <bits/stdc++.h> #include "molecules.h" #define ll long long using namespace std; const int maxn = 5e5 + 100; int n; unsigned ll bio[maxn / 64]; unsigned ll bio2[maxn / 64]; int kada[maxn]; vector<int> find_subset(int l, int u, vector<int> w) { n = w.size(); memset(kada, -1, sizeof kada); // for(int j = 63; j >= 0; j--){ // if(bio[0] && (1LL << j)) cout << 1; // else cout << 0; // } // cout << endl; bio[0] = (1LL << 63); // cout << "prije "; // for(int j = 63; j >= 0; j--){ // if(bio[0] & (1LL << j)) cout << 1; // else cout << 0; // } // cout << endl; for(int i = 0; i < n; i++){ int d = w[i] / 64; int r = w[i] % 64; for(int j = 0; j < maxn / 64; j++){ bio2[j] = bio[j]; if(j - d >= 0) bio2[j] |= (bio[j - d] >> r); if(j - d - 1 >= 0) bio2[j] |= (bio[j - d - 1] << (64 - r)); // for(int j = 63; j >= 0; j--){ // if(bio[0] & (1LL << j)) cout << 1; // else cout << 0; // } // cout << endl; } for(int j = 0; j < maxn / 64; j++){ if(bio2[j] != bio[j]){ for(int b = 0; b < 64; b++){ if((bio2[j] & (1LL << b)) && !(bio[j] & (1LL << b))) kada[(j + 1) * 64 - 1 - b] = i; } bio[j] = bio2[j]; } } } int x = 0; // for(int j = 63; j >= 0; j--){ // if(bio[0] & (1LL << j)) cout << 1; // else cout << 0; // } // cout << endl; // for(int i = 0; i <= 10; i++){ // cout << kada[i] << ' '; // } // cout << endl; for(int i = l; i <= u; i++){ if(kada[i] != -1){ x = i; break; } } vector <int> v; while(x){ v.push_back(kada[x]); x -= w[kada[x]]; } reverse(v.begin(), v.end()); return v; }
#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...