QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#109445 | #6506. Chase Game 3 | wnmrmr# | WA | 35ms | 3500kb | C++23 | 1.6kb | 2023-05-29 01:54:39 | 2023-05-29 01:54:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define pb push_back
void dbg_out() { cerr << endl; }
template <typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }
template <typename ND, typename T = typename ND::T>
struct SegIt {
int n;
vector<ND> t;
SegIt(int _n): n(_n), t(2*n) {}
SegIt(vector<T> &v): n(v.size()), t(2*n) {
for(int i=0;i<n;i++)
t[i+n] = ND(v[i]);
build();
}
void build() {
for(int i=n-1;i>0;i--)
t[i] = t[2*i] + t[2*i+1];
}
void update(int pos, T val) {
int p = pos + n ;
t[p] = ND(val);
while(p) {
p /= 2;
t[p] = t[2*p] + t[2*p+1];
}
}
ND query(int l, int r) {
ND tl, tr;
r++;
for(l += n, r += n; l < r; l /= 2, r/= 2) {
if(l&1) tl = tl + t[l++];
if(r&1) tr = t[--r] + tr;
}
return tl + tr;
}
};
struct Node {
using T = int;
T mn;
Node(): mn(numeric_limits<T>::max()) {}
Node(T x): mn(x) {}
friend Node operator+(Node lhs, Node rhs) {
return Node(min(lhs.mn, rhs.mn));
}
};
using Seg = SegIt<Node>;
const int INF = 1e9;
void solve() {
int n; cin >> n;
vector<int> p(n); for(int &x: p) cin >> x, x--;
vector<int> v(n, INF);
for(int i=0;i<n-1;i++) {
int a = p[i], b = p[i+1];
if(a > b) swap(a, b);
if(a + 1 == b) continue;
if(b - a >= 3) {
cout << "No" << '\n';
return;
}
}
cout << "Yes" << '\n';
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
int t; cin >> t;
while(t--)
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3444kb
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: 1ms
memory: 3500kb
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: 35ms
memory: 3396kb
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 Yes Yes No Yes No Yes No Yes No Yes No No No No Yes No Yes No Yes Yes Yes Yes Yes No Yes Yes No Yes Yes Yes No Yes No No Yes No No No Yes Yes Yes Yes No No No No No No Yes Yes Yes No Yes Yes Yes Yes No No Yes Yes No No No Yes Yes Yes Yes Yes Yes No No Yes Yes No No Yes No Yes No Yes Yes No ...
result:
wrong answer expected YES, found NO [1st token]