Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
33136 | liuziming | 【S】T3 | C++ | 通过 | 100 | 903 MS | 70572 KB | 813 | 2024-10-04 15:11:41 |
#include<bits/stdc++.h> using namespace std; #define int long long string s; int k,ans; map<pair<int,int>,int> pot; signed main(){ //freopen("code.in","r",stdin); cin>>s;cin>>k; int nowx=0,nowy=0,nowans=0;ans=1;pot[make_pair(nowx,nowy)]=1; for(int i=1;i<=min((long long)25,k);i++){ nowans=0; for(int i=1;i<=s.size();i++){ if(s[i-1]=='U'){ nowy++; }if(s[i-1]=='D'){ nowy--; }if(s[i-1]=='L'){ nowx++; }if(s[i-1]=='R'){ nowx--; }if(!pot[make_pair(nowx,nowy)]){ nowans++; }pot[make_pair(nowx,nowy)]=1; }ans+=nowans; }for(int i=1;i<=k-25;i++){ ans+=nowans; } cout<<ans<<'\n'; }