結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
![]() |
提出日時 | 2024-10-13 17:50:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 790 bytes |
コンパイル時間 | 775 ms |
コンパイル使用メモリ | 58,688 KB |
最終ジャッジ日時 | 2025-02-24 19:19:20 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:30:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 30 | scanf("%s", s); | ~~~~~^~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 2924.cc: No.2924 <===Super Spaceship String===> - yukicoder */ #include<cstdio> #include<cstring> #include<stack> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 500000; /* typedef */ using sti = stack<int>; /* global variables */ char s[MAX_N + 4]; /* subroutines */ /* main */ int main() { scanf("%s", s); int n = strlen(s); int l = -1, r = -1, sum = 0; sti q; for (int i = 0; i < n; i++) { if (s[i] == '<') q.push(i); else if (s[i] == '>') { if (! q.empty()) { int u = q.top(); q.pop(); if (u + 1 < i) { if (r <= u) sum += r - l; l = u, r = i + 1; } else while (! q.empty()) q.pop(); } } } if (l < r) sum += r - l; printf("%d\n", n - sum); return 0; }