結果

問題 No.2374 ASKT Subsequences
ユーザー ochiaigawaochiaigawa
提出日時 2023-07-07 22:53:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,378 bytes
コンパイル時間 1,826 ms
コンパイル使用メモリ 176,580 KB
実行使用メモリ 11,468 KB
最終ジャッジ日時 2023-09-29 00:29:50
合計ジャッジ時間 6,414 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
11,468 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int M = 2005;
int main() {
  cin.tie(0); cout.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<vector<int>> G(N), H(N), I(N);
  for(int i = 0; i < N; i++) {
    for(int j = i + 2; j < N - 1; j++) {
      if(A[j] - A[i] == 10) {
        G[i].push_back(j);
      }
    }
  }
  for(int i = 2; i < N - 1; i++) {
    for(int j = 1; j < i; j++) {
      if(A[j] > A[i]) {
        H[i].push_back(j);
      }
    }
  }
  for(int i = 1; i < N - 2; i++) {
    for(int j = i + 2; j < N; j++) {
      if(A[j] == A[i] + 1) {
        I[i].push_back(j);
      }
    }
  }
  queue<vector<int>> que;
  int ans = 0;
  for(int i = 0; i < N - 3; i++) {
    que.push({i});
    while(!que.empty()) {
      vector<int> v = que.front();
      que.pop();
      if((int) v.size() == 1) {
        for(int nex : G[v.back()]) {
          vector<int> nv = v;
          nv.push_back(nex);
          que.push(nv);
        }
      } else if((int) v.size() == 2) {
        for(int nex : H[v.back()]) {
          vector<int> nv = v;
          nv.push_back(nex);
          que.push(nv);
        }
      } else {
        for(int nex : I[v.back()]) {
          if(nex > v[1]) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
0