Submission #64036

#TimeUsernameProblemLanguageResultExecution timeMemory
64036Just_Solve_The_Problemparentrises (BOI18_parentrises)C++11
5 / 100
1067 ms568 KiB
#include <bits/stdc++.h> using namespace std; #define sz(s) (int)s.size() #define all(s) s.begin(), s.end() void solve1() { string s; cin >> s; int pw = 1; for (int i = 0; i < sz(s); i++) { pw *= 3; } int a[14]; bool fl = 0; for (int mask = 0; mask < pw; mask++) { int musk = mask; fl = 1; for (int i = sz(s) - 1; i >= 0; i--) { int bit = musk % 3; musk /= 3; a[i] = bit; } int b1, b2; b1 = b2 = 0; for (int i = 0; i < sz(s); i++) { if (a[i] < 2) { if (s[i] == '(') b1++; else b1--; if (b1 < 0) fl = 0; } if (a[i] > 0) { if (s[i] == '(') b2++; else b2--; if (b2 < 0) fl = 0; } } fl &= (b1 == 0 && b2 == 0); if (fl) { // cout << b1 << ' ' << b2 << endl; break; } } if (!fl) { puts("impossible"); } else { for (int i = 0; i < sz(s); i++) { if (a[i] == 0) printf("R"); if (a[i] == 1) printf("G"); if (a[i] == 2) printf("B"); } puts(""); } } main() { int p; scanf("%d", &p); if (p == 1) { int test; scanf("%d", &test); while (test--) solve1(); } else { } }

Compilation message (stderr)

parentrises.cpp:57:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
parentrises.cpp: In function 'int main()':
parentrises.cpp:59:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &p);
   ~~~~~^~~~~~~~~~
parentrises.cpp:62:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &test);
     ~~~~~^~~~~~~~~~~~~
#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...