竞赛讨论区 > 1-C求助
头像
星维
发布于 2022-01-25 23:00
+ 关注

1-C求助

用的自己的方法模拟.
识别冲突语句;插入空语句;消除因为插入被解决冲突的后续语句.
但是并不能过题,请大佬瞧一瞧TAT
#include <bits/stdc++.h>
using namespace std;
int world[105][3],ans;
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            scanf("%d",&world[i][j]);
        }
    }
    for(int i=0;i<n;i++){
        if(world[i][0]==1){
            ans+=3;
            world[i+1][2]=0;
            world[i+1][1]=0;
            world[i+2][2]=0;
        }
        else if(world[i][1]==1){
            ans+=2;
            world[i+1][2]=0;
            world[i+1][1]=0;
            world[i+2][2]=0;
        }
        else if(world[i][2]==1){
            ans+=1;
            world[i+1][2]=0;
            world[i+2][2]=0;
        }
    }
    printf("%d",ans);
    return 0;
}


全部评论

(2) 回帖
加载中...
话题 回帖

等你来战

查看全部

热门推荐