QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#108755#6506. Chase Game 3ckiseki#WA 29ms3436kbC++201.9kb2023-05-26 16:21:432023-05-26 16:21:46

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-26 16:21:46]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:3436kb
  • [2023-05-26 16:21:43]
  • 提交

answer

#include <bits/stdc++.h>
#ifdef CKISEKI
#define safe cerr<<__PRETTY_FUNCTION__\
    <<" line "<<__LINE__<<" safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
using std::cerr;
template <typename ...T>
void debug_(const char *s, T ...a) {
    cerr << "\e[1;32m(" << s << ") = (";
    int cnt = sizeof...(T);
    (..., (cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
template <typename I>
void orange_(const char *s, I L, I R) {
    cerr << "\e[1;32m[ " << s << " ] = [ ";
    for (int f = 0; L != R; ++L)
        cerr << (f++ ? ", " : "") << *L;
    cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) ((void)0)
#define orange(...) ((void)0)
#endif

using namespace std;

signed main() {
    cin.tie(nullptr) -> sync_with_stdio(false);
    int T;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        vector<int> p(n);
        for (int i = 0; i < n; i++)
            cin >> p[i];

        vector<tuple<int,int,int>> v;
        for (int i = 2; i < n; i++) {
            int a[3] = {
                p[i - 2],
                p[i - 1],
                p[i - 0],
            };
            sort(a, a+3);
            v.emplace_back(a[0], a[1], a[2]);
        }
        sort(v.begin(), v.end());
        bool ok = true;
        for (int i = 1; i <= n-2; i++) {
            if (v[i-1] != tuple{i, i+1, i+2}) {
                ok = false;
            }
        }
        if (ok) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }

        // if ((p[0] == 1 && p[n-1] == n) || (p[0] == n && p[n-1] == 1)) {
        //     bool ok = true;
        //     for (int i = 1; i < n; i++) {
        //         if (abs(p[i] - p[i - 1]) > 2)
        //             ok = false;
        //     }

        //     if (ok) {
        //         cout << "Yes\n";
        //     } else {
        //         cout << "No\n";
        //     }
        // } else {
        //     cout << "No\n";
        // }
    }
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3424kb

input:

5
2
1 2
3
2 3 1
4
1 4 3 2
5
1 5 2 3 4
6
1 2 3 4 5 6

output:

Yes
Yes
No
No
Yes

result:

ok 5 token(s): yes count is 3, no count is 2

Test #2:

score: 0
Accepted
time: 0ms
memory: 3424kb

input:

8
2
1 2
2
2 1
3
1 2 3
3
3 1 2
3
2 1 3
3
2 3 1
3
3 2 1
3
1 3 2

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes

result:

ok 8 token(s): yes count is 8, no count is 0

Test #3:

score: -100
Wrong Answer
time: 29ms
memory: 3436kb

input:

100000
4
4 1 3 2
4
3 2 4 1
4
3 2 1 4
4
2 4 3 1
4
1 2 3 4
4
2 3 1 4
4
1 3 4 2
4
3 4 1 2
4
1 3 2 4
4
1 4 3 2
4
3 4 2 1
4
3 2 4 1
4
4 2 3 1
4
3 2 4 1
4
4 1 2 3
4
3 2 1 4
4
4 1 3 2
4
1 3 4 2
4
1 4 2 3
4
2 4 3 1
4
2 3 1 4
4
4 2 3 1
4
2 1 3 4
4
3 1 2 4
4
1 2 3 4
4
4 3 2 1
4
3 4 1 2
4
1 3 2 4
4
4 2 1 3
4
3...

output:

No
No
No
No
Yes
No
No
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
No
Yes
No
No
Yes
Yes
No
Yes
No
No
No
No
No
No
Yes
No
No
No
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
Yes
No
No
No
No
Yes
No
No
Yes
No
Yes
Yes
No
No
No
No...

result:

wrong answer expected YES, found NO [1st token]