結果

問題 No.1834 1D Gravity
ユーザー SSRSSSRS
提出日時 2022-02-04 22:35:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 999 bytes
コンパイル時間 4,477 ms
コンパイル使用メモリ 207,980 KB
実行使用メモリ 85,336 KB
最終ジャッジ日時 2023-09-02 05:09:41
合計ジャッジ時間 8,331 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//これは嘘
#include <bits/stdc++.h>
using namespace std;
const int B = 100;
int main(){
  int N;
  cin >> N;
  vector<int> m(N);
  for (int i = 0; i < N; i++){
    cin >> m[i];
    m[i]--;
  }
  vector<vector<int>> p(B, vector<int>(N));
  for (int i = 0; i < N; i++){
    p[0][m[i]] = i;
  }
  for (int i = 0; i < B - 1; i++){
    vector<int> mx(N, 0);
    for (int j = 0; j < N; j++){
      mx[p[i][j]] = max(mx[p[i][j]], j);
    }
    for (int j = 0; j < N; j++){
      if (p[i][j] == 0){
        p[i + 1][j] = 1;
      } else if (p[i][j] == N - 1){
        p[i + 1][j] = N - 2;
      } else if (mx[p[i][j] - 1] > mx[p[i][j] + 1]){
        p[i + 1][j] = p[i][j] - 1;
      } else {
        p[i + 1][j] = p[i][j] + 1;
      }
    }
    if (i >= 2){
      if (p[i] == p[i - 2]){
        int t = i - 2;
        set<int> st;
        for (int j = 0; j < N; j++){
          st.insert(p[i][j] + p[i + 1][j]);
        }
        cout << t << ' ' << st.size() << endl;
        break;
      }
    }
  }
}
0