Submission #442555

#TimeUsernameProblemLanguageResultExecution timeMemory
442555jesus_coconutTrobojnica (COCI19_trobojnica)C++17
0 / 110
2 ms204 KiB
#include <bits/stdc++.h> #define all(a) begin(a), end(a) #define dbg(x) cerr << #x << " = " << x << '\n'; #define F first #define S second using namespace std; using ll = long long; void solve() { int n; cin >> n; list<pair<int, int>> l; for (int i = 0; i < n; ++i) { char c; cin >> c; l.push_back({i + 1, c - '0'}); } vector<array<int, 3>> ans; int cnt = 0; for (auto it = l.begin(); cnt < 500000; ++cnt) { auto sit = l.begin(); if (next(it) != l.end()) { sit = next(it); } if (it->second != sit->second) { auto nit = next(sit); if (nit == l.end()) nit = l.begin(); if (next(nit) == it || (next(nit) == l.end() && l.begin() == it)) { if (it->S + sit->S + nit->S != 6) { cout << "NE\n"; return; } else { break; } } ans.push_back({it->F, nit->F, 6 - it->S - sit->S}); it->second = 6 - it->S - sit->S; l.erase(sit); if (it != l.begin()) { it = prev(it); } else { it = prev(l.end()); } } else { if (next(it) != l.end()) { it = next(it); } else it = l.begin(); } if (ans.size() > n - 3) { cout << "NE\n"; return; } } if (ans.size() != n - 3) { cout << "NE\n"; return; } cout << "DA\n"; for (auto &arr : ans) { for (auto a : arr) { cout << a << ' '; } cout << '\n'; } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }

Compilation message (stderr)

trobojnica.cpp: In function 'void solve()':
trobojnica.cpp:52:18: warning: comparison of integer expressions of different signedness: 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |   if (ans.size() > n - 3) {
      |       ~~~~~~~~~~~^~~~~~~
trobojnica.cpp:57:17: warning: comparison of integer expressions of different signedness: 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |  if (ans.size() != n - 3) {
      |      ~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...