Rating changes for the last round are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
95231801 Contestant:
kstheking
1430D - 6 GNU C++17 Accepted 30 ms 716 KB 2020-10-11 13:11:55 2020-10-12 02:32:08
 
 
→ Source
#include<bits/stdc++.h>
using namespace std;
using li = long int;
using lli  = long long int;

#define eb emplace_back
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pi pair <int,int>
#define vi vector <int>
#define vl vector <lli>
#define p(x) cout << #x << " is " << (x) << " on Line:" << __LINE__ << " \n";
#define pl(x) for(auto &y:x) cout << y << " "; cout << "\n";

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int _;
  cin >> _;
  while(_--){
	int n;
	cin >> n;
	string s;
	cin >> s;
	bool vis[n] = {0};//cuts
	int i = 0,j = 0, counter = 0;
	while(i < n){
		while(i < n-1){
			if((i < n-1) && (s[i] == s[i+1])){
				break;
			}
			else ++i;
		}
		vis[i] = true;
		//empty condition
		char c = s[j];
		while(j < n){
			if(vis[j]){
				++j;
			}
			else{
				if(s[j] == c) ++j;
				else break;
			}
		}
		i = max(j, i+1);
		++counter;
	}
	int temp = 0;
	for(int k = j; k < n; ++k){
		if(!vis[k])++temp;
	}
	counter += (temp+1)/2;
	cout << counter << "\n";
  }
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details