Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
37742 | LYLAKIOI | 【BJ】T3 | C++ | 运行超时 | 81 | 2012 MS | 262268 KB | 1398 | 2025-05-07 15:00:39 |
#include<bits/stdc++.h> #include<bits/extc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define pi pair<int,int> #define p1 first #define p2 second #define m_p make_pair #define p_b push_back using namespace std; using namespace __gnu_pbds; typedef long long ll; const int maxn=1e5+10,mod=998244353; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } int n; string s; ll g(ll u,char c){ if(c=='E')return u+1; if(c=='W')return u-1; if(c=='N')return u+mod; return u-mod; } void slv(){ read();n=read();cin>>s; int k=min(n,100); auto solve=[](int n){ unordered_set<ll>mp; ll p=0; up(i,1,n){ mp.insert(p); for(char c:s){ p=g(p,c); mp.insert(p); } } int res=0; for(auto it:mp){ bool ok=1; for(ll d:{1,mod,mod+1})ok&=mp.count(it+d); res+=ok; } return res; }; if(n<=100)cout<<solve(n); else cout<<solve(100)+(solve(101)-solve(100))*1ll*(n-100); } int main(){ //freopen("resist.in","r",stdin),freopen("resist.out","w",stdout); slv(); return 0; }