結果
| 問題 |
No.3032 ホモトピー入門
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-21 22:52:42 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 98 ms / 2,000 ms |
| コード長 | 990 bytes |
| コンパイル時間 | 3,757 ms |
| コンパイル使用メモリ | 281,160 KB |
| 実行使用メモリ | 13,280 KB |
| 最終ジャッジ日時 | 2025-02-21 22:52:48 |
| 合計ジャッジ時間 | 6,376 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(a) begin(a),end(a)
#define sz(a) (int)(a).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const ll mod=998244353;
int main(){
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int N,M;cin>>N>>M;
int ans=0;
while(N--){
string S;cin>>S;
ll x=0,y=0;
stack<pii>st;
rep(i,0,sz(S)){
ll _x=x,_y=y;
if(S[i]=='L')x--;
else if(S[i]=='R')x++;
else if(S[i]=='U')y++;
else y--;
if(y==0&&_y==1){
if(x==0)st.emplace(pii(0,-1));
else if(x<0)st.emplace(pii(-1,-1));
else st.emplace(pii(1,-1));
}
else if(y==1&&_y==0){
if(x==0)st.emplace(pii(0,1));
else if(x<0)st.emplace(pii(-1,1));
else st.emplace(pii(1,1));
}
while(sz(st)>1){
auto u=st.top();st.pop();
auto v=st.top();
if(u.first==v.first)st.pop();
else{st.emplace(u);break;}
}
}
if(!sz(st))ans++;
}
cout<<ans<<endl;
}