1804_ykm's blog

By 1804_ykm, history, 11 months ago, In English

The first Test point WA, help!!!

Attached question address:1367A

#include<bits/stdc++.h>
using namespace std;
int n,flag;
string s;
int main(){
	cin>>n;
	while(n--){
		cin>>s;
		for(int i=0;i<s.size();i++){
			if(s[i]!=s[i-1]&&flag>0){
				cout<<s[i];
				flag=0;
			}
			else{
				flag++;
			}	
		}
		cout<<endl;
	}
	return 0;
}

  • Vote: I like it
  • -10
  • Vote: I do not like it

»
11 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by 1804_ykm (previous revision, new revision, compare).

»
11 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Your code is leaving out the first letter of the answer. You should fix it by putting cout << s[0] before the for loop.

  • »
    »
    11 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    @mustard_with_fries69420,Thank you, it's already passed