Submission #622697

#TimeUsernameProblemLanguageResultExecution timeMemory
622697SAADDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms284 KiB
#define F first #define S second #define rep(i,a,b) for(int i=a;!(a==b&&i!=b)&&((i<=b&&b>=a)||(i>=b&&a>=b));i+=(a<=b?1:-1)) #define pb push_back #define Fbitl __builtin_ffs #define bit1 __builtin_popcount #include <iostream> #include <math.h> #include <algorithm> #include <string.h> #include <vector> #include <queue> #include <map> #include <unordered_map> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<string, string> pss; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vii; typedef vector<ll> vl; typedef vector<vl> vvl; #include "molecules.h" ll cm[(int)(2*1e5) + 5]; vector<int> find_subset(int l, int u, vector<int> w) { vii s; vi res; for (int i = 0; i < w.size(); i++) { s.push_back({ w[i],i }); } sort(s.begin(), s.end()); ll sum = 0 ; for (int i = 0; i < s.size(); i++) { sum += s[i].first; cm[i] = sum; } for (int i = 1; i <= s.size(); i++) { ll mn = cm[i-1] , mx = cm[s.size()-1] - (s.size() - i - 1 >=0?cm[s.size()-i-1]:0) ; if (mn > u || mx < l) continue; int k = i , l = 0 , r = i-1 ; sum = mn; while (r < s.size()) { ll num = cm[r] - (l - 1 >= 0 ? cm[l - 1] : 0); if ( num >= l && num <= u) { for (int i = l; i <= r; i++) { res.push_back(s[i].second); } break; } } break; } return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 0; i < w.size(); i++) {
      |                     ~~^~~~~~~~~~
molecules.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i = 0; i < s.size(); i++) {
      |                     ~~^~~~~~~~~~
molecules.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 1; i <= s.size(); i++) {
      |                     ~~^~~~~~~~~~~
molecules.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         while (r < s.size()) {
      |                ~~^~~~~~~~~~
molecules.cpp:43:13: warning: unused variable 'k' [-Wunused-variable]
   43 |         int k = i , l = 0 , r = i-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...