QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#112641 | #6604. Kobolds and Catacombs | sinbad | WA | 163ms | 10920kb | C++ | 4.2kb | 2023-06-12 17:18:30 | 2023-06-12 17:18:34 |
Judging History
answer
// #define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const multiset<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
template <class T> auto vect(const T& v, int n) { return vector<T>(n, v); }
template <class T, class... D> auto vect(const T& v, int n, D... m) {
return vector<decltype(vect(v, m...))>(n, vect(v, m...));
}
using int64 = long long;
using int128 = __int128_t;
using ii = pair<int, int>;
#define SZ(x) (int)((x).size())
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
mt19937_64 mrand(random_device{}());
int64 rnd(int64 x) { return mrand() % x; }
constexpr inline int lg2(int64 x) { return x == 0 ? -1 : sizeof(int64) * 8 - 1 - __builtin_clzll(x); }
constexpr inline int p2ceil(int64 x) { return 1 << (lg2(x - 1) + 1); }
template <class T> void out(const vector<T>& a) { for (int i = 0; i < SZ(a); ++i) cout << a[i] << " \n"[i + 1 == SZ(a)]; }
template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template <class T> void dedup(vector<T>& v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); }
inline void add_mod(int& x, int y) { x += y; if (x >= MOD) x -= MOD; }
inline void sub_mod(int& x, int y) { x += MOD - y; if (x >= MOD) x -= MOD; }
inline int mod(int x) { return x >= MOD ? x - MOD : x; }
struct fast_ios {
fast_ios() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
};
} fast_ios_;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
auto b = a;
sort(b.begin(), b.end());
int ret = 0;
for (int i = 0, j; i < n; i = j) {
int mn = inf<int>, mx = -inf<int>;
for (j = i; j < n; ++j) {
ckmin(mn, a[j]);
ckmax(mx, a[j]);
if (b[i] == mn && b[j] == mx) {
j += 1;
break;
}
}
trace(i, j);
++ret;
}
cout << ret << '\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3420kb
input:
5 1 3 2 7 4
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 134ms
memory: 10816kb
input:
1000000 524227301 431992275 758916082 293029389 719487809 413407585 7533705 414925441 87316769 639877621 980912701 739058961 277730843 958292661 778325685 500280161 782766985 339709027 1968001 842653531 847517701 989893001 97622801 728458741 612188545 787566057 981715521 281901909 804267925 89113887...
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 123ms
memory: 10740kb
input:
1000000 917949585 857260961 756665311 378355301 764449441 412507811 172034129 259899788 32062001 770226301 952621053 541484449 569936821 627592441 215749889 859777895 354928623 873704001 816399789 991063481 915131641 712367896 390917421 345695004 999782016 716109223 361816825 689562663 101790565 284...
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 60ms
memory: 10912kb
input:
1000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
1000000
result:
ok 1 number(s): "1000000"
Test #5:
score: 0
Accepted
time: 86ms
memory: 10788kb
input:
1000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000...
output:
1000000
result:
ok 1 number(s): "1000000"
Test #6:
score: 0
Accepted
time: 77ms
memory: 10720kb
input:
1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...
output:
1000000
result:
ok 1 number(s): "1000000"
Test #7:
score: 0
Accepted
time: 71ms
memory: 10752kb
input:
1000000 1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976 999975 999974 999973 999972 999971 999970 999969 999968 999967 999966 999965 999964 999963 999962 999961 999960 9999...
output:
1
result:
ok 1 number(s): "1"
Test #8:
score: 0
Accepted
time: 97ms
memory: 10768kb
input:
1000000 644593 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 644101 26 27 28 29 30 31 32 643568 34 35 330711 339005 38 39 40 578571 42 43 44 45 46 47 48 49 50 683111 52 53 54 936601 56 26971 58 59 60 909777 62 63 64 479605 66 67 68 69 216503 71 72 133286 74 75 76 77 78 950161 80 81 82...
output:
5
result:
ok 1 number(s): "5"
Test #9:
score: 0
Accepted
time: 109ms
memory: 10728kb
input:
1000000 925960 484918 999998 999997 999996 999995 999994 999993 999992 999991 396232 999989 999988 999987 999986 909136 999984 999983 999982 999981 546797 999979 999978 999977 370720 999975 999974 999973 889900 999971 999970 999969 428403 999967 999966 999965 941125 999963 999962 999961 999960 99995...
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 1ms
memory: 3404kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #11:
score: 0
Accepted
time: 2ms
memory: 3400kb
input:
1 1000000000
output:
1
result:
ok 1 number(s): "1"
Test #12:
score: 0
Accepted
time: 2ms
memory: 3468kb
input:
2 1 2
output:
2
result:
ok 1 number(s): "2"
Test #13:
score: 0
Accepted
time: 2ms
memory: 3368kb
input:
2 999999999 1
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 154ms
memory: 10736kb
input:
1000000 586342723 439528582 534325601 527397441 69111047 708525733 964567125 797408989 657663242 361074481 351855001 683394036 768478938 866430981 391488941 139668993 315700283 301683796 950938618 652811201 895030718 762246051 758513505 431480309 505858381 868633425 709348153 39897089 874006729 1198...
output:
1
result:
ok 1 number(s): "1"
Test #15:
score: 0
Accepted
time: 157ms
memory: 10736kb
input:
1000000 954794397 659831876 690237901 61500881 278431281 156748253 446041221 842695161 546785671 773749926 485956147 609494627 400435921 8377321 766721779 136618697 931232625 872057921 658877059 522113233 796888245 82127761 841077901 652095691 764639540 484453926 33179521 433549441 760785241 3486318...
output:
1
result:
ok 1 number(s): "1"
Test #16:
score: 0
Accepted
time: 163ms
memory: 10920kb
input:
1000000 128840331 879801121 670528493 901520277 287501561 470233351 378643431 513453281 682933401 790677901 165011489 984840511 127177501 429591681 278342801 752147841 692314989 832989249 467306522 456552948 423884289 191857613 158974681 426788513 149616705 324894881 957251929 843413581 77455801 979...
output:
1
result:
ok 1 number(s): "1"
Test #17:
score: 0
Accepted
time: 157ms
memory: 10816kb
input:
1000000 161013121 664403189 614216489 698442181 219647457 436165251 998498409 287752251 300275311 329438101 56648611 639847201 79783786 5691119 696920001 52923297 311784066 955714611 683832021 689830541 968313713 402592241 253942497 83948056 913972223 937838081 473079781 824166351 597287105 96825832...
output:
1
result:
ok 1 number(s): "1"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
8 1 3 2 3 6 2 5 6
output:
3
result:
ok 1 number(s): "3"
Test #19:
score: 0
Accepted
time: 159ms
memory: 10840kb
input:
1000000 348603270 386489122 792347481 27525121 667073584 115812337 134287200 258350511 332395268 375550921 502896103 295131939 143975927 795532616 197869196 846653636 228314507 415916495 517260515 196147295 867164299 894042139 22756037 722783489 719220461 805450377 563763902 777821091 896997777 8903...
output:
1
result:
ok 1 number(s): "1"
Test #20:
score: 0
Accepted
time: 139ms
memory: 10832kb
input:
1000000 56634598 428227608 19522053 242809901 401989342 153025312 224845591 240854860 394067282 352068261 522475269 300940456 190603259 455385252 277245202 485676557 504775078 161021043 75658391 341134830 409186096 335951473 39642707 8723116 127948234 20429577 399891664 384185051 381383129 62263082 ...
output:
2
result:
ok 1 number(s): "2"
Test #21:
score: 0
Accepted
time: 138ms
memory: 10744kb
input:
1000000 2964650 2299663 8139936 13199093 9208575 4758946 8241190 15985766 3634932 8112467 10175282 16805645 2731708 13506221 7066034 6492929 16956227 14465831 7065500 2904292 10678923 10328524 4573371 5320116 19519541 19646251 19494587 17351340 10239937 5766449 19390853 9197581 19482445 10148179 967...
output:
5
result:
ok 1 number(s): "5"
Test #22:
score: 0
Accepted
time: 154ms
memory: 10748kb
input:
1000000 70886765 90822620 43509215 38420340 72869197 36311986 33046932 41293580 103389449 74941262 74679761 47248903 89686382 79141363 8299741 70408426 78616751 86005516 24406309 74551615 53411315 34963038 33480938 47028510 47051496 102235690 91957303 98693911 73424812 98414240 88750631 33191275 182...
output:
10
result:
ok 1 number(s): "10"
Test #23:
score: 0
Accepted
time: 149ms
memory: 10904kb
input:
1000000 2974782 9228256 5373417 5225670 12762913 6651739 4622571 10086454 4806207 8114662 3891123 9811262 6339928 12149346 3073194 7132033 8748385 7777124 11936013 4357232 461683 12004042 8265960 9070067 466116 6220864 11667841 1191131 7395597 3701044 5301163 7903111 8809860 6461836 9761040 11536840...
output:
20
result:
ok 1 number(s): "20"
Test #24:
score: 0
Accepted
time: 154ms
memory: 10796kb
input:
1000000 503153 13203042 1936420 11801093 19550439 15184444 7801125 6373872 6382987 750851 17915404 181244 8873423 13371191 843131 13890391 18086834 15413539 13046899 10341296 7155921 18225826 5813679 476964 7010009 16760704 16763925 2303511 20915226 15431582 17102771 13206133 16090461 1538713 157223...
output:
50
result:
ok 1 number(s): "50"
Test #25:
score: 0
Accepted
time: 127ms
memory: 10808kb
input:
1000000 6632052 2613632 12141307 7311661 11104750 2051635 10756174 11598054 7813891 10271133 13713084 9690023 12445780 3689866 517100 667833 5811890 9249207 127133 5275768 13300402 1700910 5543713 9304836 4843827 3323577 9537078 12614321 1883530 4481712 10621440 8972112 6876308 13290565 7433771 6882...
output:
100
result:
ok 1 number(s): "100"
Test #26:
score: 0
Accepted
time: 131ms
memory: 10748kb
input:
1000000 8044193 3766100 11989762 3626801 12249212 9788253 10556935 119135 276506 11498478 5539413 11946975 14335468 1990695 5618952 2471628 8341412 13393806 5200684 9346471 3144893 2754965 9689593 1903532 11017469 9038707 13490272 3995380 7347997 10421401 12130659 317831 9376283 610918 14661030 1300...
output:
200
result:
ok 1 number(s): "200"
Test #27:
score: 0
Accepted
time: 110ms
memory: 10812kb
input:
1000000 26452 134261 101963 100203 43611 10232 477577 23567 160937 56138 80871 267686 79481 66805 335224 438457 146131 137429 95412 325200 15665 298681 181687 621374 328234 178871 614857 154311 384483 430616 171755 402226 467575 258928 252736 179563 391796 40371 51220 436469 342206 68093 508145 1718...
output:
503
result:
ok 1 number(s): "503"
Test #28:
score: 0
Accepted
time: 128ms
memory: 10772kb
input:
1000000 148316 790571 1227672 440861 507642 235908 1316746 547791 595620 522772 86173 401714 645616 69196 728228 628191 308978 46367 1083256 301330 771610 955413 310118 1048574 763719 761893 1121132 473733 452609 904108 708081 300323 352837 1275677 557365 1310107 472685 404945 1194438 14961 955424 6...
output:
1007
result:
ok 1 number(s): "1007"
Test #29:
score: -100
Wrong Answer
time: 134ms
memory: 10748kb
input:
1000000 155268 152201 72753 149387 77736 129815 140565 35558 22098 14162 17901 29833 80655 53164 68190 6344 16568 108715 69583 62144 50643 139417 2206 98738 119616 49239 32359 102926 108355 157591 123949 37392 30032 129540 58879 44036 102046 86760 15540 55768 104846 90996 132182 117527 51757 32256 1...
output:
1072
result:
wrong answer 1st numbers differ - expected: '2056', found: '1072'