Submission #538283

#TimeUsernameProblemLanguageResultExecution timeMemory
538283timreizinLinear Garden (IOI08_linear_garden)C++17
24 / 100
1579 ms4256 KiB
#include <iostream> #include <vector> #include <queue> #include <algorithm> #include <array> #include <set> #include <string> using namespace std; using ll = long long; const ll MOD = 1e9 + 7; bool check(string s) { for (int i = 0; i < s.size(); ++i) { int cntL = 0; for (int l = 1; i + l - 1 < s.size(); ++l) { cntL += s[i + l - 1] == 'L'; int cntP = l - cntL; if (abs(cntP - cntL) > 2) return false; } } return true; } int main() { cin.tie(0)->sync_with_stdio(0); int n; ll m; string s; cin >> n >> m >> s; vector<string> gardens; check("PLPPL"); for (ll i = 0; i < (1 << n); ++i) { string s(n, 'L'); for (int j = 0; j < n; ++j) if (i & (1 << j)) s[j] = 'P'; if (check(s)) gardens.push_back(s); } sort(gardens.begin(), gardens.end()); for (int i = 0; i < gardens.size(); ++i) { if (gardens[i] == s) { cout << (i + 1) % m; break; } } return 0; }

Compilation message (stderr)

linear_garden.cpp: In function 'bool check(std::string)':
linear_garden.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < s.size(); ++i)
      |                     ~~^~~~~~~~~~
linear_garden.cpp:20:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for (int l = 1; i + l - 1 < s.size(); ++l)
      |                         ~~~~~~~~~~^~~~~~~~~~
linear_garden.cpp: In function 'int main()':
linear_garden.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (int i = 0; i < gardens.size(); ++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...
#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...
#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...
#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...