結果

問題 No.3086 Re One Two
ユーザー pengin_2000
提出日時 2025-04-04 21:54:37
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 1,229 ms
コンパイル使用メモリ 24,832 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2025-04-04 21:55:05
合計ジャッジ時間 5,373 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:10:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |                 scanf("%d %d", &a[i], &b[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int a[200005], b[200005];
int next[200005], id;
int main()
{
	int n;
	scanf("%d", &n);
	int i, j;
	for (i = 0; i < n; i++)
		scanf("%d %d", &a[i], &b[i]);
	for (i = 0; i < n; i++)
		next[i] = -1;
	id = -1;
	for (i = 0; i < n; i++)
	{
		if (b[i] == 2)
		{
			id = i;
			continue;
		}
		if (b[i] == 1)
		{
			next[i] = id;
		}
		if (a[i] == 1)
		{
			next[i + 1] = i;
			continue;
		}
		for (j = i; j >= 0; j = next[j])
			printf("%d\n", j + 1);
	}
	return 0;
}
0