Friday, January 31, 2014

codechef ATTIC - "attic crossing" solution

codechef ATTIC - "attic crossing" : http://www.codechef.com/problems/ATTIC
codechef ATTIC - "attic crossing" editorial : http://discuss.codechef.com/questions/15030/attic-editorial

codechef ATTIC - "attic crossing" solution :  http://ideone.com/MSO5OR

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
int t, day, max, step;
char s[1000009];
scanf("%d", &t);
while(t--) {
day=0;
max=0;
step=0;
scanf("%s", s);
for(int i=0; i<strlen(s); i++) {
if(s[i]=='#') day=0;
else day++;
if(day>max && s[i+1]=='#') {
max=day;
step++;
}
}
printf("%d\n", step);
}
return 0;
}

No comments:

Post a Comment