Submission #1024879

#TimeUsernameProblemLanguageResultExecution timeMemory
1024879slivajanDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms604 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long un; typedef vector<un> vuc; #define REP(i, a, b) for(un i = a; i < b; i++) #define FEAC(i, a) for (auto&& i : a) #define vec vector #define ALL(x) (x).begin(), (x).end() std::vector<int> find_subset(int l, int u, std::vector<int> w) { vec<pair<un, un>> toSort(w.size()); REP(i, 0, w.size()) toSort[i] = {w[i], i}; sort(ALL(toSort)); vuc tab(w.size()); REP(i, 0, w.size()){ w[i] = toSort[i].first; tab[i] = toSort[i].second; } un ls = 0; un rs = 0; un ptr = 0; while((ls < l) and (rs < l)){ ls += w[ptr]; rs += w[w.size() - ptr - 1]; ptr++; } if (ls > u){ return {}; } vec<int> ret(ptr); iota(ALL(ret), 0); un newptr = 0; while(ls < l){ ret[newptr] = w.size() - 1 - newptr; ls += (w[ret[newptr]] - w[newptr]); } REP(i, 0, ret.size()){ ret[i] = tab[ret[i]]; } return ret; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:38: warning: comparison of integer expressions of different signedness: 'un' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define REP(i, a, b) for(un i = a; i < b; i++)
......
   18 |     REP(i, 0, w.size()) toSort[i] = {w[i], i};
      |         ~~~~~~~~~~~~~~                
molecules.cpp:18:5: note: in expansion of macro 'REP'
   18 |     REP(i, 0, w.size()) toSort[i] = {w[i], i};
      |     ^~~
molecules.cpp:9:38: warning: comparison of integer expressions of different signedness: 'un' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define REP(i, a, b) for(un i = a; i < b; i++)
......
   24 |     REP(i, 0, w.size()){
      |         ~~~~~~~~~~~~~~                
molecules.cpp:24:5: note: in expansion of macro 'REP'
   24 |     REP(i, 0, w.size()){
      |     ^~~
molecules.cpp:9:38: warning: comparison of integer expressions of different signedness: 'un' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define REP(i, a, b) for(un i = a; i < b; i++)
......
   54 |     REP(i, 0, ret.size()){
      |         ~~~~~~~~~~~~~~~~              
molecules.cpp:54:5: note: in expansion of macro 'REP'
   54 |     REP(i, 0, ret.size()){
      |     ^~~
#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...