제출 #780715

#제출 시각아이디문제언어결과실행 시간메모리
780715JoenPoenManDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms212 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ALL(arr) begin(arr), end(arr) typedef pair<int, int> ii; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<bool> subset(w.size(), false); priority_queue<ii> sw; priority_queue<ii> rsw; long int sum = 0; for (int i = 0; i < w.size(); i++) { sw.push({w[i], i}); rsw.push({w[i], i}); } while (sum < l) { auto [weight, ind] = sw.top(); sw.pop(); sum += weight; subset[ind] = true; } int prevInd = -1; int prevRemInd = -1; for (int attempts = 2*w.size(); attempts >= 0; attempts--) { if (sum < l) { auto [weight, ind] = sw.top(); sw.pop(); subset[ind] = true; sum += weight; } else if (sum > u) { bool suc = false; while (!suc) { auto [weight, ind] = rsw.top(); rsw.pop(); if (subset[ind] = true) { suc = true; subset[ind] = false; sum -= weight; } } } else { vector<int> res; for (int n = 0; n < subset.size(); n++) if (subset[n]) res.push_back(n); return res; } } return std::vector<int>(0); }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (int i = 0; i < w.size(); i++) {
      |                     ~~^~~~~~~~~~
molecules.cpp:46:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             for (int n = 0; n < subset.size(); n++) if (subset[n]) res.push_back(n);
      |                             ~~^~~~~~~~~~~~~~~
molecules.cpp:25:9: warning: unused variable 'prevInd' [-Wunused-variable]
   25 |     int prevInd = -1;
      |         ^~~~~~~
molecules.cpp:26:9: warning: unused variable 'prevRemInd' [-Wunused-variable]
   26 |     int prevRemInd = -1;
      |         ^~~~~~~~~~
#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...