結果
| 問題 |
No.3032 ホモトピー入門
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-21 23:41:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,256 bytes |
| コンパイル時間 | 2,625 ms |
| コンパイル使用メモリ | 207,232 KB |
| 実行使用メモリ | 10,552 KB |
| 最終ジャッジ日時 | 2025-02-21 23:41:52 |
| 合計ジャッジ時間 | 17,881 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void Yes(){cout << "YES\n";}
void No(){cout << "NO\n";}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int T; cin >> T;
int answer = 0,N; cin >> N;
while(T--){
string s; cin >> s;
{
string t = "";
for(auto c : s){
if(t.size()){
if(set<char>{t.back(),c} == set<char>{'L','R'} || set<char>{t.back(),c} == set<char>{'U','D'}) t.pop_back();
else t += c;
}
else t += c;
}
s = t;
}
int x = 0,y = 0;
set<int> c1L,c2L,c1R,c2R;
for(auto c : s){
if(c == 'L' && y > 0){
if(x == 1) c2L.insert(y);
if(x == 0) c1L.insert(y);
}
if(c == 'R' && y > 0){
if(x == -1) c1R.insert(y);
if(x == 0) c2R.insert(y);
}
if(c == 'L') x--;
else if(c == 'R') x++;
else if(c == 'U') y++;
else y--;
}
int c1 = c1L.size()+c1R.size(),c2 = c2L.size()+c2R.size();
if(c1%2 == 0 && c2%2 == 0) answer++;
}
cout << answer << endl;
}