QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#684189#9430. Left Shifting 2Akoasm_XWA 0ms3764kbC++201.2kb2024-10-28 11:10:362024-10-28 11:10:37

Judging History

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

  • [2024-10-28 11:10:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3764kb
  • [2024-10-28 11:10:36]
  • 提交

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 ;
}

const int maxn = 5e5+20;
int n;
char s1[maxn],s2[maxn];

void solve(int T){
    scanf("%s",s1);
    n = strlen(s1);
    for(int i=0;i<n;i++) s2[i] = s1[i];
    int ans = 0;
    for(int i=1;i<n;i++){
        if(s1[i]==s1[i-1]){
            for(int j=0;i+j<n;j++) s2[j] = s1[i+j];
            for(int j=0;j<i;j++) s2[n-i+j] = s1[j];
            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("%s\n",s2);
    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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3764kb

input:

3
abccbbbbd
abcde
x

output:

cbbbbdabc
2
abcdedabc
0
xbcdedabc
0

result:

wrong answer 1st lines differ - expected: '2', found: 'cbbbbdabc'