Submission #1041768

#TimeUsernameProblemLanguageResultExecution timeMemory
1041768NeroZeinTricolor Lights (JOI24_tricolor)C++17
0 / 100
41 ms1396 KiB
#include "Anna.h" #include <bits/stdc++.h> using namespace std; const char d[] = {'R', 'G', 'B'}; pair<string, int> anna(int N, string S) { int n = N; string s = S; string t(n, '0'); if (n <= 130) { for (int i = 0; i < n; ++i) { for (char c : d) { if (c != s[i]) { t[i] = c; break; } } } return {t, n}; } map<char, int> mp; for (char c : s) { mp[c]++; } vector<char> candidates; for (char c : d) { if (c != s[129]) { candidates.push_back(c); } } int chosen = 0; if (mp[candidates[1]] > n / 2) { chosen = 1; } //now the unchosen appears atmost n / 2 times. vector<char> unchosen; for (char c : d) { if (c != candidates[chosen]) { unchosen.push_back(c); } } assert(unchosen.size() == 2 && candidates.size() == 2); s[129] = candidates[chosen]; for (int i = 0, last = 0; i < n; ++i) { if (i == 129) { continue; } if (s[i] != unchosen[last ^ 1]) { t[i] = unchosen[last ^ 1]; last ^= 1; } else { t[i] = unchosen[last]; } } return {t, 130}; }
#include "Bruno.h" #include <bits/stdc++.h> using namespace std; int n, l; void init(int N, int l_) { n = N, l = l_; } int bruno(string u) { if (n <= 130) { return 1; } map<char, int> mp; for (char c : u) { mp[c]++; } int ind = -1; for (int i = 0; i < l; ++i) { if (mp[u[i]] == 1) { assert(ind == -1); ind = i; } } return 1 + (129 - ind); }
#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...