답안 #69987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
69987 2018-08-22T08:02:01 Z octopuses parentrises (BOI18_parentrises) C++17
0 / 100
3 ms 536 KB
//Giorgi Kldiashvili

#include <bits/stdc++.h>

#define ll long long
#define fr first
#define sc second
#define M 1000000007ll

using namespace std;

const int N = 1000020;

int n, k;
int used[N];
bool f[N];
char ch[N];

void go1()
{
  vector < int > c; c.clear();
  scanf("%s", &ch);
  n = strlen(ch);
  for(int i = 0; i < n; ++ i)
    used[i] = 0, f[i] = 0;
  if(ch[0] == ')' || ch[n - 1] == '(')
  {
    printf("impossible\n");
    return;
  }
  int now = 1;
  for(int i = 1; i < n; ++ i)
  {
    if(ch[i] == ')' && ch[i] == ch[i - 1] && !(f[i - 1]))
      c.push_back(i - 1), f[i] = true;
    now += (ch[i] == ')')?-1:1;
    if(now < 0)
    {
      if(c.size() == 0)
      {
        printf("impossible\n");
        return;
      }
      used[c.back()] = 1;
      used[c.back() + 1] = 2;
      c.pop_back();
      now = 0;
    }
  }
  now = 1;
  c.clear();
  for(int i = n - 1; i >= 0; -- i) f[i] = 0;
  for(int i = n - 2; i >= 0; -- i)
  {
    if(ch[i] == '(' && ch[i] == ch[i + 1] && !(f[i + 1]))
      c.push_back(i), f[i] = true;
    now += (ch[i] == '(')?-1:1;
    if(now < 0)
    {
      if(c.size() == 0)
      {
        printf("impossible\n");
        return;
      }
      used[c.back()] = 1;
      used[c.back() + 1] = 2;
      c.pop_back();
      now = 0;
    }
  }
  for(int i = 0; i < n; ++ i)
  {
    if(used[i] == 0) putchar('G');
    if(used[i] == 1) putchar('R');
    if(used[i] == 2) putchar('B');
  }
  printf("\n");
}

int sub, T;

int main()
{
  scanf("%d", &sub);
  scanf("%d\n", &T);
  if(sub == 1)
  {
    while(T --)
      go1();
  }
}

Compilation message

parentrises.cpp: In function 'void go1()':
parentrises.cpp:22:18: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[1000020]' [-Wformat=]
   scanf("%s", &ch);
               ~~~^
parentrises.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", &ch);
   ~~~~~^~~~~~~~~~~
parentrises.cpp: In function 'int main()':
parentrises.cpp:84:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &sub);
   ~~~~~^~~~~~~~~~~~
parentrises.cpp:85:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d\n", &T);
   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 460 KB Output is correct
2 Incorrect 3 ms 536 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 460 KB Output is correct
2 Incorrect 3 ms 536 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 460 KB Output is correct
2 Incorrect 3 ms 536 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 536 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 536 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 536 KB Unexpected end of file - int32 expected