結果
問題 |
No.3032 ホモトピー入門
|
ユーザー |
|
提出日時 | 2025-02-21 22:30:38 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 138 ms / 2,000 ms |
コード長 | 1,470 bytes |
コンパイル時間 | 6,148 ms |
コンパイル使用メモリ | 334,212 KB |
実行使用メモリ | 25,748 KB |
最終ジャッジ日時 | 2025-02-21 22:30:50 |
合計ジャッジ時間 | 9,578 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using mint = atcoder::static_modint<998244353>; // // using mint = atcoder::static_modint<1000000007>; using ld = long double; using ll = long long; #define mp(a,b) make_pair(a,b) #define rep(i,s,n) for(int i=s; i<(int)n; i++) const vector<int> dx{1,0,-1,0},dy{0,1,0,-1}; int n,m; bool solve(){ string s;cin >> s; ll x=0,y=0; //通過位置と通過方向のペア vector<pair<int,int>> A; vector<pair<int,int>> B; for(char c:s){ ll u=x,v=y; if(c=='U')v++; if(c=='D')v--; if(c=='R')u++; if(c=='L')u--; // cout << u << " " << v << "\n"; if((2*y-1)*(2*v-1)<0){ //y=0.5を縦断 pair<int,int> p; if(x<0)p.first=-1; else if(x==0)p.first=0; else p.first=1; if(y==0){ //下から上に通過 p.second=1; } else{ //上から下 p.second=-1; } if(A.size()>0 && A.back().first==p.first && A.back().second==-p.second)A.pop_back(); else A.push_back(p); B.push_back(p); } x=u,y=v; } // for(auto [x,y]:B)cout << x << " " << y << "\n"; // cout << "\n"; return A.size()==0; } int main(){ cin >> n >> m; int ans=0; rep(i,0,n)ans+=solve(); cout << ans; }