蒟蒻求助
查看原帖
蒟蒻求助
855663
0x0001cxr楼主2023/1/16 17:55

4个RE 数组加大1就TLE 求AC

#include<bits/stdc++.h>
using namespace std;

struct hulk
{
    int x;
    string str;
    int sr;
};
hulk o[100000];
int a[100000];
int s[100000];
int main()
{
    int n, m, ans = 1;
    cin >> n >> m;
    for(int i = 1;i <= n;i++)
    {
        cin >> o[i].x >> o[i].str;
        o[i].sr = i;
    }
    for(int i = 1;i <= m;i++)
    {
        cin >> a[i] >> s[i];
    }
    for(int i = 1;i <= m;i++)
    {
        int mid = ans;
        if(a[i] == 0 && o[mid].x == 0)
        {
            for(int j = 0;j < s[i];j++)
            {
                if(o[ans].sr == 1)
                {
                    ans += n;
                }
                ans--;
            }
        }
        if(a[i] == 0 && o[mid].x == 1)
        {
            for(int j = 0;j < s[i];j++)
            {
                if(o[ans].sr == n)
                {
                    ans -= n;
                }
                ans++;
            }
        }
        if(a[i] == 1 && o[mid].x == 0)
        {
            for(int j = 0;j < s[i];j++)
            {
                if(o[ans].sr == n)
                {
                    ans -= n;
                }
                ans++;
            }
        }
        if(a[i] == 1 && o[mid].x == 1)
        {
            for(int j = 0;j < s[i];j++)
            {
                if(o[ans].sr == 1)
                {
                    ans += n;
                }
                ans--;
            }
        }
    }
    cout << o[ans].str << endl;
    return 0;
}
2023/1/16 17:55
加载中...