結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
![]() |
提出日時 | 2024-10-12 16:34:57 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 667 bytes |
コンパイル時間 | 713 ms |
コンパイル使用メモリ | 29,184 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-16 17:55:37 |
合計ジャッジ時間 | 1,368 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include<stdio.h> char s[500005]; char t[500005]; int b[500005]; int main() { scanf("%s", s); int n; for (n = 0; s[n] != '\0'; n++); int tt = 0, i; for (i = 0; i < n; i++) { if (tt == 0) { t[tt] = s[i]; if (s[i] == '<') b[tt] = tt; else b[tt] = -1; tt++; } else { if (s[i] == '<') { t[tt] = '<'; b[tt] = tt; tt++; } else if (s[i] == '>') { if (b[tt - 1] < 0 || b[tt - 1] == tt - 1) { t[tt] = '>'; b[tt] = -1; tt++; } else { tt = b[tt - 1]; } } else { t[tt] = '='; b[tt] = b[tt - 1]; tt++; } } } printf("%lld\n", tt); return 0; }