QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#684172 | #9430. Left Shifting 2 | Akoasm_X | RE | 0ms | 3544kb | C++20 | 1.3kb | 2024-10-28 11:05:02 | 2024-10-28 11:05:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define int long long
#define endl "\n"
typedef long long LL;
inline int read(){
int x = 0 , f = 1 ; char c = getchar() ;
while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
return x * f ;
}
void solve(int T){
string s,s2;
cin>>s;
s2 = s;
// if(5000 - T==34) cout<<s<<endl;
int n = s.length();
int ans = 0;
for(int i=1;i<n;i++){
if(s[i]==s[i-1]){
// cout<<i<<endl;
for(int j=0;i+j<n;j++) s[i+j];
for(int j=0;j<i;j++) s[j];
// puts("");
for(int j=0;i+j<n;j++) s2[j] = s[i+j];
for(int j=0;j<i;j++) s2[i+j] = s[j];
// cout<<s2<<endl;
break;
}
}
// for(int i=0;i<n;i++) cout<<s2[i];
for(int i=1;i<n;i++){
if(s2[i]==s2[i-1]){
i++;
ans++;
}
}
// cout<<s2<<endl;
cout<<ans<<endl;
// printf("%d\n",ans);
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// freopen("1.txt","r",stdin);
int T = 1;
// T = read();
cin>>T;
while(T--) solve(T);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
3 abccbbbbd abcde x
output:
2 0 0
result:
ok 3 lines
Test #2:
score: -100
Runtime Error
input:
5000 lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh cfliuqnynejgnxolzbdoztclzbozqomvioszk eiivcoqoymonrqgrjdtkts mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf ujeqtidwtoikkqtygo llma qjfvgwrdhaazejsfgilnpmmhkefndzvyon kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx vftculoorxskpkxoz...