| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 70033 | octopuses | parentrises (BOI18_parentrises) | C++17 | 281 ms | 9624 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Giorgi Kldiashvili
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define M 1000000007
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);
  int A, B; A = B = 0;
  for(int i = 0; i < n; ++ i)
  {
    if(ch[i] == '(') A ++;
    if(ch[i] == ')') B ++;
    if(B > A * 2)
    {
      printf("impossible\n");
      return;
    }
  }
  A = B = 0;
  for(int i = n - 1; i >= 0; -- i)
  {
    if(ch[i] == ')') A ++;
    if(ch[i] == '(') B ++;
    if(B > A * 2)
    {
      printf("impossible\n");
      return;
    }
  }
  for(int i = 0; i < n; ++ i)
    used[i] = 0, f[i] = 0;
  int now = 1;
  for(int i = 1; i < n; ++ i)
  {
    if(ch[i] == ')')
      c.push_back(i);
    now += (ch[i] == ')')?-1:1;
    if(now < 0)
    {
      used[c.back()] = 1; c.pop_back();
      used[c.back()] = 2; c.pop_back();
      now = 0;
    }
  }
  now = 1;
  c.clear();
  if(used[n - 1] == 2) now = 0;
  for(int i = n - 2; i >= 0; -- i)
  {
    if(used[i] == 2) continue;
    if(ch[i] == '(')
      c.push_back(i);
    now += (ch[i] == '(')?-1:1;
    if(now < 0)
    {
      used[c.back()] = 1; c.pop_back();
      used[c.back()] = 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 A[2][305][910];
int answer[305];
void go2()
{
  A[0][1][302] = 1;
  int now = 1;
  int pre = 0;
  for(int i = 2; i <= 300; ++ i)
  {
    for(int p = 1; p <= i; ++ p)
    {
      for(int q = 2; q <= 905; ++ q)
      {
        if(p * 2 < i - p)
        {
          A[now][p][q] = 0;
          continue;
        }
        A[now][p][q] = A[pre][p][q - 2];
        if(q < 302) A[now][p][q] += A[pre][p - 1][q + 1];
        if(A[now][p][q] >= M) A[now][p][q] -= M;
        if(q >= 303)
          answer[i] = (answer[i] + A[now][p][q]) % M;
      }
      if(p * 2 < i - p) continue;
      for(int q = 303; q <= 905; ++ q)
        A[now][p][302] = (A[now][p][302] + A[pre][p - 1][q]) % M;
    }
    swap(now, pre);
  }
}
int sub, T;
int main()
{
  scanf("%d", &sub);
  scanf("%d\n", &T);
  if(sub == 1)
  {
    while(T --)
      go1();
  } else
  {
    go2();
    while(T --)
    {
      scanf("%d", &n);
      printf("%d\n", answer[n]);
    }
  }
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
