QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#684172#9430. Left Shifting 2Akoasm_XRE 0ms3544kbC++201.3kb2024-10-28 11:05:022024-10-28 11:05:03

Judging History

你现在查看的是最新测评结果

  • [2024-10-28 11:05:03]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3544kb
  • [2024-10-28 11:05:02]
  • 提交

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...

output:


result: