全WA求助
查看原帖
全WA求助
912750
CarrotMeow楼主2023/3/11 22:43

好像思路没问题,但全 WA\footnotesize\colorbox{Red}{\color{White}\textsf{WA}}

#include <bits/stdc++.h>

#define fo(i,a,b) for (auto i = a; i < b; i ++)
#define foe(i,a,b) for (auto i = a; i <= b; i ++)
#define of(i,b,a) for (auto i = b; i > a; i --)
#define ofe(i,b,a) for (auto i = b; i >= a; i --)
#define fi(i,s) for (auto i : s)
#define print(fmt, ...) printf(fmt, __VA_ARGS__), printf("\n") 
#define sq(x) ((x) * (x))
#define cb(x) (sq(x) * (x))
#define ks(s) (string(s))
#define ts(s) (to_string(s))
#define mem(s, a) memset(s, a, sizeof(s))
#define v1 first
#define v2 second

using namespace std;

typedef long long ll;
typedef unsigned ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int inf = 0x3f3f3f3f;
const ll inf_ll = 0x3f3f3f3f3f3f3f3fll;

template<class _Tp, const size_t __len> 
using arr = _Tp [__len];


stack<int> a;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    int q, n;
    cin >> q;
    while (q --) {
        a = {};
        cin >> n;
        int pushed[n + 1], poped[n + 1];
        foe (i, 1, n) cin >> pushed[i];
        foe (i, 1, n) cin >> poped[i];
        foe (i, 1, n) {
            a.push(pushed[i]);
            for (int j = 1; a.top() == poped[j]; j ++) {
                a.pop();
                if (a.empty()) break;
            }
        }
        if (a.size()) printf("No\n");
        else printf("Yes\n");
    }
}

为甚么???

2023/3/11 22:43
加载中...