TLE四点求调,必关
查看原帖
TLE四点求调,必关
1057189
a_day_plus楼主2024/8/20 22:11
#include <bits/stdc++.h>
using namespace std;
struct stu{
    bool in_or_out;
    string name;
};
stu a[100005];
int n,m;
int pos=1;

int do_something(int st,int l_or_r,int num){
    int tn;
    if(a[st].in_or_out){
        if(l_or_r){
            tn=-1;
        }
        else{
            tn =1;
        }
    }
    else{
        if(l_or_r){
            tn=1;
        }
        else{
            tn=-1;
        }
    }
    while(num){
        st+=tn;
        if(st==0){
            st=n;
        }
        if(st==n+1){
            st=1;
        }
        num--;
    }
    return st;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i].in_or_out>>a[i].name;
    }
    for(int i=1;i<=m;i++){
        int t1,t2;
        cin>>t1>>t2;
        pos=do_something(pos,t1,t2);
    }
    cout<<a[pos].name;
}
2024/8/20 22:11
加载中...