結果

問題 No.3086 Re One Two
ユーザー tnakao0123
提出日時 2025-04-08 15:08:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 676 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 41,088 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-08 15:08:40
合計ジャッジ時間 5,887 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
main.cpp:29:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |   for (int i = 0; i < n; i++) scanf("%d%d", as + i, bs + i);
      |                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 3086.cc:  No.3086 Re One Two - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int as[MAX_N], bs[MAX_N];
int ps[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", as + i, bs + i);

  fill(ps, ps + n, -1);
  for (int i = 0, j = 0; i < n; i++) {
    if (as[i] == 1) ps[i + 1] = i;
    else if (bs[i] == 2) {
      while (bs[j] != 1) j++;
      ps[j++] = i;
    }
    else {
      for (int u = i; u >= 0; u = ps[u])
	printf("%d\n", u + 1);
    }
  }

  return 0;
}
0