Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int count, now, n, m;
- char in[101];
- void findBlock(){
- for(int i=0;i<strlen(in);i++){
- if(in[i]=='|'){
- now = i;
- count++;
- return;
- }
- if(in[i]=='/'){
- (i-1<0?now=0:now=i-1);
- count++;
- return;
- }
- if(in[i]=='\\'){
- (i+1>m-1?now=m-1:now=i+1);
- count++;
- return;
- }
- }
- now = 101;
- }
- int main(){
- int tc;
- scanf("%d",&tc);
- for(int i=1;i<=tc;i++){
- count = 0, now = 101;
- scanf("%d %d",&n,&m);
- scanf("%s",in);
- findBlock();
- for(int j=1;j<n;j++){
- if(in[now]!='.' && now!=101){
- if(in[now]=='\\')(now+1>m-1?now:now++);
- if(in[now]=='/')(now-1<0?now:now--);
- }
- scanf("%s", in);
- if(in[now]=='.' || now == 101){
- findBlock();
- }
- }
- printf("Case #%d: %d\n",i,count);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement