Submission #521711

#TimeUsernameProblemLanguageResultExecution timeMemory
521711MateGiorbelidzeDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms296 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> a) { vector <int> ans; ll n = a.size() , p [n + 1] , cnt = 0 , j = 0; vector <int> b(n) , used(n); for (int i = 0 ; i < n; i++){ b[i] = a[i]; used[i] = 0; } sort(a.begin(),a.end()); p[0] = a[0]; if (a[0] >= l && a[0] <= r) { ans.pb(0); return ans; } for (int i = 1; i < n; i++) { p[i] = p[i - 1] + a[i]; if (p[i] >= l && p[i] <= r) { j = i; break; } if (p[i] > r) { if (p[i] - a[0]>= l && p[i] - a[0] <= r) { cnt = 1 ; j = i; } break; } } if (j == 0) return ans; if (cnt == 1) { for (int i = 1; i <= j; i++) { for (int k = 0; k < n ; k++) { if (a[i] == b[k] && used[k] == 0) { ans.pb(k); used[k] = 1; break; } } } } else { for (int i = 0; i <= j; i++) { for (int k = 0; k < n ; k++) { if (a[i] == b[k] && used[k] == 0) { ans.pb(k); used[k] = 1; break; } } } } 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:46:19: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   46 |    if (p[i] - a[0]>= l && p[i] - a[0] <= r) {
      |        ~~~~~~~~~~~^~~~
molecules.cpp:46:39: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   46 |    if (p[i] - a[0]>= l && p[i] - a[0] <= r) {
      |                           ~~~~~~~~~~~~^~~~
molecules.cpp:62:21: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   62 |   for (int i = 1; i <= j; i++) {
      |                   ~~^~~~
molecules.cpp:64:22: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   64 |    for (int k = 0; k < n ; k++) {
      |                    ~~^~~
molecules.cpp:83:21: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   83 |   for (int i = 0; i <= j; i++) {
      |                   ~~^~~~
molecules.cpp:85:22: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   85 |    for (int k = 0; k < n ; k++) {
      |                    ~~^~~
#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...