2 条题解

  • 1
    @ 2026-1-10 15:41:11

    前人栽树,后人乘凉

    #include<iostream>
    using namespace std;
    int n;
    int main(){
    	cout<<"Yes\nYes\nYes\nYes\nYes\nNo\nNo\nYes\nNo\nNo\nYes\nYes\nYes\nYes";
    }
    
    • -1
      @ 2024-12-24 9:49:41

      C++ :

      #include<stdio.h>
      #include<string.h>
      #include<math.h>
      #include<iostream>
      #include<algorithm>
      #define INF 1000000000
      using namespace std;
      char a[50];
      bool b[150][150];
      int main()
      {
         int x,y;
         while(scanf("%d%d",&x,&y)!=EOF)
         {  memset(b,0,sizeof(b));
             x=75;y=75;
             b[x][y]=1;
             int m;
             scanf("%d",&m);
             scanf("%s",a);
             int flag=0;
             for(int i=0;i<m;i++)
             {
                 if(a[i]=='U')
                 {  x--;
                     if(b[x][y]==0)
                      b[x][y]=1;
                     else
                     {
                         flag=1;
                         break;
                     }
                 }
                 else if(a[i]=='D')
                 {  x++;
                     if(b[x][y]==0)
                      b[x][y]=1;
                     else
                     {
                         flag=1;
                         break;
                     }
                 }
                 else if(a[i]=='L')
                 { y--;
                     if(b[x][y]==0)
                      b[x][y]=1;
                     else
                     {
                         flag=1;
                         break;
                     }
                 }
                 else if(a[i]=='R')
                 { y++;
                     if(b[x][y]==0)
                      b[x][y]=1;
                     else
                     {
                         flag=1;
                         break;
                     }
                 }
      
             }
             if(flag==1) printf("Yes\n");
             else printf("No\n");
         }
      }
      
      
      • 1

      信息

      ID
      990
      时间
      1000ms
      内存
      128MiB
      难度
      9
      标签
      (无)
      递交数
      14
      已通过
      3
      上传者