Submission #652417

#TimeUsernameProblemLanguageResultExecution timeMemory
652417BlagojPrisoner Challenge (IOI22_prison)C++17
30 / 100
32 ms2128 KiB
#include "prison.h" #include <bits/stdc++.h> using namespace std; std::vector<std::vector<int>> devise_strategy(int N) { vector<vector<int>> v(50); for (int i = 0; i <= 49; i++) { if (i == 0) { v[i].push_back(0); for (int j = 1; j <= N; j++) { string a = to_string(j); v[i].push_back(a.size() + 4); } continue; } if (i >= 5 && i <= 8) { v[i].push_back(1); for (int j = 1; j <= N; j++) { string b = to_string(j); if (b.size() + 4 == i) { v[i].push_back(9); } else { if (b.size() + 4 < i) { v[i].push_back(-2); } if (i < b.size() + 4) { v[i].push_back(-1); } } } continue; } if (i == 9) { v[i].push_back(0); for (int j = 1; j <= N; j++) { int k = j; while (k > 9) { k /= 10; } v[i].push_back(10 + k); } continue; } if (i >= 1 && i <= 3) { v[i].push_back(0); for (int j = 1; j <= N; j++) { int k = j, l = 9999; if (i == 1) { l = 99; } if (i == 2) { l = 999; } while (k > l) { k /= 10; } string a = to_string(j); if (a.size() < i + 1) { v[i].push_back(-1); continue; } v[i].push_back(min((i + 1) * 10 + k % 10, 49)); } continue; } v[i].push_back(1); for (int j = 1; j <= N; j++) { int k = j, l = 9999; if (i / 10 == 1) { l = 9; } if (i / 10 == 2) { l = 99; } if (i / 10 == 3) { l = 999; } while (k > l) { k /= 10; } k %= 10; string b = to_string(j); if (b.size() < i / 10) { v[i].push_back(-2); continue; } if (k > i % 10) { v[i].push_back(-1); continue; } if (k < i % 10) { v[i].push_back(-2); continue; } v[i].push_back(i / 10); } continue; } return v; }

Compilation message (stderr)

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:26:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |         if (b.size() + 4 == i)
      |             ~~~~~~~~~~~~~^~~~
prison.cpp:32:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |           if (b.size() + 4 < i)
      |               ~~~~~~~~~~~~~^~~
prison.cpp:36:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |           if (i < b.size() + 4)
      |               ~~^~~~~~~~~~~~~~
prison.cpp:77:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   77 |         if (a.size() < i + 1)
      |             ~~~~~~~~~^~~~~~~
prison.cpp:108:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  108 |       if (b.size() < i / 10)
      |           ~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...