Submission #64036

# Submission time Handle Problem Language Result Execution time Memory
64036 2018-08-03T08:37:06 Z Just_Solve_The_Problem parentrises (BOI18_parentrises) C++11
5 / 100
1000 ms 568 KB
#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

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 time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 480 KB Output is correct
3 Correct 3 ms 496 KB Output is correct
4 Correct 114 ms 568 KB Output is correct
5 Correct 827 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 568 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 568 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 568 KB Unexpected end of file - int32 expected