Submission #521719

#TimeUsernameProblemLanguageResultExecution timeMemory
521719MateGiorbelidzeDetecting Molecules (IOI16_molecules)C++14
100 / 100
48 ms8608 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll unsigned long long #define ff first #define sc second #define pb push_back vector<int> find_subset(int l, int r, vector<int> b) { vector <int> ans(0); ll n = b.size() , p [n + 1] , cnt = 0 , j = 0; vector < pair<int,int> > a(n) , used(n); for (int i = 0 ; i < n; i++){ a[i].ff = b[i]; a[i].sc = i; } sort(a.begin(),a.end()); p[0] = a[0].ff; if (a[0].ff >= l && a[0].ff <= r) { ans.pb(0); return ans; } for (int i = 1; i < n; i++) { p[i] = p[i - 1] + a[i].ff; if (p[i] >= l && p[i] <= r) { j = i; break; } if (p[i] > r) { cnt = i ; break; } } if (j == 0 && cnt == 0) return ans; if (cnt == 0) { for (int i = 0; i <= j; i++) { ans.pb(a[i].sc); } } else { ll s = p[cnt - 1]; for (int i = 0; i < cnt; i++) { s -= a[i].ff; s += a[n - i - 1].ff; if (s >= l && s <= r) { j = i + 1; break; } } if (j == 0) return ans; for (int i = j; i < cnt; i++) { ans.pb(a[i].sc); } for (int i = n - j; i < n; i++) { ans.pb(a[i].sc); } } sort(ans.begin(),ans.end()); return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:17:24: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   17 |     for (int i = 0 ; i < n; i++){
      |                      ~~^~~
molecules.cpp:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   34 |     for (int i = 1; i < n; i++) {
      |                     ~~^~~
molecules.cpp:38:15: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   38 |      if (p[i] >= l && p[i] <= r) {
      |          ~~~~~^~~~
molecules.cpp:38:28: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   38 |      if (p[i] >= l && p[i] <= r) {
      |                       ~~~~~^~~~
molecules.cpp:44:12: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   44 |   if (p[i] > r) {
      |       ~~~~~^~~
molecules.cpp:58:21: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   58 |   for (int i = 0; i <= j; i++) {
      |                   ~~^~~~
molecules.cpp:69:21: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   69 |   for (int i = 0; i < cnt; i++) {
      |                   ~~^~~~~
molecules.cpp:75:10: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   75 |    if (s >= l && s <= r) {
      |        ~~^~~~
molecules.cpp:75:20: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   75 |    if (s >= l && s <= r) {
      |                  ~~^~~~
molecules.cpp:87:21: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   87 |   for (int i = j; i < cnt; i++) {
      |                   ~~^~~~~
molecules.cpp:93:25: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   93 |   for (int i = n - j; i < n; 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...