6 条题解

  • 0
    @ 2024-6-2 19:31:49
    #include<bits/stdc++.h> 
    using namespace std;
    const int N = 1e5+10;
    struct nxde
    {
    	int dir;
    	string name;
    } a[N];
    int n,m,x,y,pos = 1;
    int main(){
    	cin >> n >> m;
    	for(int i = 1;i <= n;i++)
    	    cin>>a[i].dir>>a[i].name;
    	while(m--)
    	{
    		cin >> x >> y;
    		if(a[pos].dir == 0 && x == 0||a[pos].dir == 1&&x == 1)
    		    pos -= y;
    		else
    		    pos += y;
    		while(pos <= 0) pos += n;
    		pos = (pos - 1)%n+1;
    	}
    	cout<<a[pos].name;
    	return 0;
    }
    
    • 0
      @ 2024-6-2 19:31:20
      #include<iostream>
      #include<cstdio>
      #include<string>
      #include<bits/stdc++.h>
      #define LL long long
      using namespace std;
      const int INF=0x3f3f3f3f;
      const int N=2e5+10;
      struct node{
      	int fx;
      	string name;
      }a[N];
      int n,m,x,y,pos=1;
      int main(){
      	cin>>n>>m;
      	for(int i=1;i<=n;i++){
      		cin>>a[i].fx>>a[i].name;
      	}
      	while(m--){
      		cin>>x>>y;
      		if(a[pos].fx==0&&x==0||a[pos].fx==1&&x==1) pos-=y;
      		else pos+=y;
      		while(pos<=0) pos+=n;
      		pos=(pos-1)%n+1;
      	}
      	cout<<a[pos].name;
      }
      
      • 0

        #include<iostream> using namespace std; const int N = 1e5 + 10; const int INF = 0X3f3f3f;

        struct node { bool id; string name; }a[N];

        int n , m , x , y , pos = 1; int main(){ cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i].id >> a[i].name;

        while(m--)
        {
        	cin >> x >> y;
        	if( !a[pos].id && x || a[pos].id && !x )
        	    pos += y;
        	else
        	    pos -= y;
        	while( pos <= 0) pos += n;
        	pos = (pos - 1) % n + 1;	    
        }   
        cout << a[pos].name;
        
        
        
        
        
        return 0;
        

        }

        • 0
          @ 2024-6-2 18:22:03

          最简题解

          #include<bits/stdc++.h>
          using namespace std;
          
          const int N=1e6+10;
          struct node{bool id;string nm;}a[N];
          long long n,m,x,y,cnt=1;
          
          int main(){
          	cin>>n>>m;
          	for(int i=1;i<=n;i++)cin>>a[i].id>>a[i].nm;
          	while(m--){
          		cin>>x>>y;
          		if(!a[cnt].id&&x||a[cnt].id&&!x)cnt+=y;
          		else cnt-=y;
          		while(cnt<=0)cnt+=n;
          		cnt=(cnt-1)%n+1;
          	}cout<<a[cnt].nm;
          	return 0;
          }
          
          • 0
            @ 2024-5-19 16:27:09
            /*
            int      %o/%lo(八进制) %d/%i/%ld/%li(十进制) %x/%lx(十六进制)[如标名为o/lo/d/i/lo/li/x/lx即输出为八进制/十进制/十六进制]
            longlong %lld
            float    %f/%e
            double   %lf/%le
            char     %c
            char[]   %s
            'a'=97
            'z'=122
            'A'=65
            'Z'=90
            '0'=48
            '9'=57
            */
            #include <iostream>
            #include <iomanip>
            #include <cmath>
            #include <cstdio>
            #include <cstring>
            #include <algorithm>
            using namespace std;
            #define LL long long
            const int N=1e5+10;
            const int INF=0x3f3f3f3f;
            const double pi=3.1416;
            int n,m,x,y,cnt=1;
            struct sb
            {
            	int fx;
            	string name;
            } a[N];
            
            int main()
            {
            	cin>>n>>m;
            	for(int i=1; i<=n; i++)
            	{
            		cin>>a[i].fx>>a[i].name;
            	}
            	while(m--)
            	{
            		cin>>x>>y;
            		if(a[cnt].fx==0&&x==0||(a[cnt].fx==1&&x==1))
            		{
            			cnt=cnt-y;
            		}
            		else
            		{
            			cnt=cnt+y;
            		}
            		while(cnt<=0)
            		{
            			cnt+=n;
            		}
            		cnt=(cnt-1)%n+1;
            	}
            	cout<<a[cnt].name;
            	return 0;
            }
            
            • 0
              @ 2024-2-27 23:02:31
              #include <queue>
              #include <math.h>
              #include <stack>
              #include <stdio.h>
              #include <iostream>
              #include <vector>
              #include <iomanip>
              #include <string.h>
              #include <algorithm>
              #include<fstream>
              using namespace std;
              #define LL long long
              const int N = 1e5 + 10;
              const int INF = 0x3f3f3f3f;
              int n, m,cnt = 1;
              struct node
              {
              	int fx;
              	string name;
              }a[N];
              int x, y;
              int main()
              {
              	freopen("toy.in", "r", stdin);
              	freopen("toy.out", "w", stdout);
              	cin >> n >> m;
              	for (int i = 1; i <= n; i++)
              	{
              		cin >> a[i].fx>>a[i].name;
              	}
              	while (m--)
              	{
              		cin >> x >> y;
              		if (x == 0 && a[cnt].fx || x == 1 && a[cnt].fx == 0)
              			cnt += y;
              		else
              			cnt -= y;
              		while (cnt <= 0)
              			cnt += n;
              		while (cnt > n)
              			cnt -= n;
              
              	}
              	cout << a[cnt].name << endl;
              	return 0;
              }
              
              • 1

              信息

              ID
              762
              时间
              1000ms
              内存
              256MiB
              难度
              8
              标签
              递交数
              198
              已通过
              37
              上传者