Submission #288723

#TimeUsernameProblemLanguageResultExecution timeMemory
288723OzyBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
1 ms512 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define debug(a) cerr << #a << " = " << a << endl vector<int> izq,der,arr; vector<long long int> cizq, cder; long long int costo(vector<long long int> V,int pos, int K) { long long int res; res = 0; if (pos >= 0 && pos < V.size()) return V[pos]; return res; } long long delivery(int N, int K, int L, int p[]) { long long int mitad,a,ini,fin,b,cont,Ma,Mb; long long int res,MIN,sum,l; res = 0; mitad = L/2; izq.clear(); der.clear(); arr.clear(); cizq.clear(); cder.clear(); rep(i,0,N-1) { if (p[i] <= mitad) izq.push_back(p[i]); else der.push_back(L - p[i]); } if (!der.empty()) reverse(der.begin(), der.end()); rep(i, 0, izq.size() - 1){ if (i >= K) cizq.push_back((2 * izq[i]) + cizq[i - K]); else cizq.push_back(2 * izq[i]); } rep(i, 0, der.size() - 1){ if (i >= K) cder.push_back((2 * der[i]) + cder[i - K]); else cder.push_back(2 * der[i]); } MIN = costo(cder,der.size()-1,K) + costo(cizq,izq.size()-1,K); rep(i,0,K) { a = L + costo(cder,der.size()-1-i,K) + costo(cizq, izq.size()-1-(K-i) ,K); MIN = min(MIN,a); } cerr << MIN; return MIN; }

Compilation message (stderr)

boxes.cpp: In function 'long long int costo(std::vector<long long int>, int, int)':
boxes.cpp:17:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     if (pos >= 0 && pos < V.size()) return V[pos];
      |                     ~~~~^~~~~~~~~~
boxes.cpp:12:58: warning: unused parameter 'K' [-Wunused-parameter]
   12 | long long int costo(vector<long long int> V,int pos, int K) {
      |                                                      ~~~~^
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:5:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i,a,b) for (int i = (a); i <= (b); i++)
      |                                        ^
boxes.cpp:40:5: note: in expansion of macro 'rep'
   40 |     rep(i, 0, izq.size() - 1){
      |     ^~~
boxes.cpp:5:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i,a,b) for (int i = (a); i <= (b); i++)
      |                                        ^
boxes.cpp:45:5: note: in expansion of macro 'rep'
   45 |     rep(i, 0, der.size() - 1){
      |     ^~~
boxes.cpp:50:32: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   50 |     MIN = costo(cder,der.size()-1,K) + costo(cizq,izq.size()-1,K);
      |                      ~~~~~~~~~~^~
boxes.cpp:50:61: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   50 |     MIN = costo(cder,der.size()-1,K) + costo(cizq,izq.size()-1,K);
      |                                                   ~~~~~~~~~~^~
boxes.cpp:54:40: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   54 |         a = L + costo(cder,der.size()-1-i,K) + costo(cizq, izq.size()-1-(K-i) ,K);
      |                            ~~~~~~~~~~~~^~
boxes.cpp:54:72: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   54 |         a = L + costo(cder,der.size()-1-i,K) + costo(cizq, izq.size()-1-(K-i) ,K);
      |                                                            ~~~~~~~~~~~~^~~~~~
boxes.cpp:23:27: warning: unused variable 'ini' [-Wunused-variable]
   23 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                           ^~~
boxes.cpp:23:31: warning: unused variable 'fin' [-Wunused-variable]
   23 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                               ^~~
boxes.cpp:23:35: warning: unused variable 'b' [-Wunused-variable]
   23 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                   ^
boxes.cpp:23:37: warning: unused variable 'cont' [-Wunused-variable]
   23 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                     ^~~~
boxes.cpp:23:42: warning: unused variable 'Ma' [-Wunused-variable]
   23 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                          ^~
boxes.cpp:23:45: warning: unused variable 'Mb' [-Wunused-variable]
   23 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                             ^~
boxes.cpp:24:19: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   24 |     long long int res,MIN,sum,l;
      |                   ^~~
boxes.cpp:24:27: warning: unused variable 'sum' [-Wunused-variable]
   24 |     long long int res,MIN,sum,l;
      |                           ^~~
boxes.cpp:24:31: warning: unused variable 'l' [-Wunused-variable]
   24 |     long long int res,MIN,sum,l;
      |                               ^
#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...