QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#132563#6506. Chase Game 3ClHg2AC ✓22ms6600kbC++141.6kb2023-07-30 16:15:042023-07-30 16:15:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-30 16:15:07]
  • 评测
  • 测评结果:AC
  • 用时:22ms
  • 内存:6600kb
  • [2023-07-30 16:15:04]
  • 提交

answer

#include <array>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>

namespace {
using std::cin;
using std::cout;
using std::int64_t;
using std::size_t;

namespace base {
template <typename T, size_t... sizes>
struct NestedArray {};

template <typename T, size_t size, size_t... sizes>
struct NestedArray<T, size, sizes...> {
  using Type = std::array<typename NestedArray<T, sizes...>::Type, size>;
};

template <typename T>
struct NestedArray<T> {
  using Type = T;
};

template <typename T, size_t... sizes>
using Array = typename NestedArray<T, sizes...>::Type;

void OptimizeIO() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
}

void OptimizeIO(const std::string &input_file, const std::string &output_file) {
  static std::ifstream input_stream(input_file);
  static std::ofstream output_stream(output_file);
  cin.rdbuf(input_stream.rdbuf()), cout.rdbuf(output_stream.rdbuf());
  cin.tie(nullptr), cout.tie(nullptr);
}
}  // namespace base

using base::Array;

const int kMaxN = 4.0e5 + 5;
int n;
Array<int, kMaxN> p, q;

void Solve() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> p[i];
  for (int i = 1; i <= n; ++i) q[p[i]] = i;

  for (int i = 1; i < n; ++i) {
    if (std::abs(q[i] - q[i + 1]) > 2) {
      cout << "No\n";
      return;
    }
  }

  cout << "Yes\n";
}

int Main() {
  base::OptimizeIO();
  int t;
  cin >> t;
  while (t--) Solve();
  return 0;
}
}  // namespace

int main() { return Main(); }

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3592kb

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: 3488kb

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: 0
Accepted
time: 18ms
memory: 3488kb

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:

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

result:

ok 100000 token(s): yes count is 49924, no count is 50076

Test #4:

score: 0
Accepted
time: 13ms
memory: 3500kb

input:

40320
8
6 4 5 1 7 2 8 3
8
6 4 5 1 8 2 7 3
8
7 4 5 1 6 2 8 3
8
7 4 5 1 8 2 6 3
8
8 4 5 1 6 2 7 3
8
8 4 5 1 7 2 6 3
8
5 4 6 1 7 2 8 3
8
5 4 6 1 8 2 7 3
8
7 4 6 1 5 2 8 3
8
7 4 6 1 8 2 5 3
8
8 4 6 1 5 2 7 3
8
8 4 6 1 7 2 5 3
8
5 4 7 1 6 2 8 3
8
5 4 7 1 8 2 6 3
8
6 4 7 1 5 2 8 3
8
6 4 7 1 8 2 5 3
8
8 4 ...

output:

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

result:

ok 40320 token(s): yes count is 88, no count is 40232

Test #5:

score: 0
Accepted
time: 20ms
memory: 4996kb

input:

101
1999
1999 1 1998 2 1997 3 1996 4 1995 5 1994 6 1993 7 1992 8 1991 9 1990 10 1989 11 1988 12 1987 13 1986 14 1985 15 1984 16 1983 17 1982 18 1981 19 1980 20 1979 21 1978 22 1977 23 1976 24 1975 25 1974 26 1973 27 1972 28 1971 29 1970 30 1969 31 1968 32 1967 33 1966 34 1965 35 1964 36 1963 37 1962...

output:

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

result:

ok 101 token(s): yes count is 56, no count is 45

Test #6:

score: 0
Accepted
time: 17ms
memory: 5160kb

input:

1001
200000
10016 115603 92772 90818 194898 114432 69682 171243 112669 182917 2208 8742 197223 117119 115493 123485 143881 146553 177669 171876 155454 106048 12153 23393 5816 167107 158874 24238 96193 120675 153645 165417 170920 54084 86652 176121 86747 22534 36192 14282 139372 174679 196019 97354 4...

output:

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

result:

ok 1001 token(s): yes count is 573, no count is 428

Test #7:

score: 0
Accepted
time: 22ms
memory: 6592kb

input:

1
400000
8943 80702 57493 189252 152036 76138 274037 171452 80112 335291 313535 94347 324988 282976 143972 166970 11939 266646 347617 234302 362239 20442 153044 21151 164399 289181 146875 190255 214216 366441 111916 226337 101752 342370 75878 33963 369142 51397 92080 215383 132623 96918 251672 27426...

output:

No

result:

ok NO

Test #8:

score: 0
Accepted
time: 16ms
memory: 6600kb

input:

1
400000
84917 84916 84918 84915 84919 84914 84920 84913 84921 84912 84922 84911 84923 84910 84924 84909 84925 84908 84926 84907 84927 84906 84928 84905 84929 84904 84930 84903 84931 84902 84932 84901 84933 84900 84934 84899 84935 84898 84936 84897 84937 84896 84938 84895 84939 84894 84940 84893 849...

output:

Yes

result:

ok YES