QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#835580#9917. The Story of Emperor Bieucup-team112#AC ✓50ms12972kbC++2010.9kb2024-12-28 13:05:122024-12-28 13:05:15

Judging History

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

  • [2024-12-28 13:05:15]
  • 评测
  • 测评结果:AC
  • 用时:50ms
  • 内存:12972kb
  • [2024-12-28 13:05:12]
  • 提交

answer

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #define INTERACTIVE

#include <bits/stdc++.h>
using namespace std;

namespace templates {
// type
using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pil = pair<int, ll>;
using Pli = pair<ll, int>;
using Pll = pair<ll, ll>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using qp = priority_queue<T, vector<T>, greater<T>>;
// clang-format off
#define vec(T, A, ...) vector<T> A(__VA_ARGS__);
#define vvec(T, A, h, ...) vector<vector<T>> A(h, vector<T>(__VA_ARGS__));
#define vvvec(T, A, h1, h2, ...) vector<vector<vector<T>>> A(h1, vector<vector<T>>(h2, vector<T>(__VA_ARGS__)));
// clang-format on

// for loop
#define fori1(a) for (ll _ = 0; _ < (a); _++)
#define fori2(i, a) for (ll i = 0; i < (a); i++)
#define fori3(i, a, b) for (ll i = (a); i < (b); i++)
#define fori4(i, a, b, c) for (ll i = (a); ((c) > 0 || i > (b)) && ((c) < 0 || i < (b)); i += (c))
#define overload4(a, b, c, d, e, ...) e
#define fori(...) overload4(__VA_ARGS__, fori4, fori3, fori2, fori1)(__VA_ARGS__)

// declare and input
// clang-format off
#define INT(...) int __VA_ARGS__; inp(__VA_ARGS__);
#define LL(...) ll __VA_ARGS__; inp(__VA_ARGS__);
#define STRING(...) string __VA_ARGS__; inp(__VA_ARGS__);
#define CHAR(...) char __VA_ARGS__; inp(__VA_ARGS__);
#define DOUBLE(...) double __VA_ARGS__; STRING(str___); __VA_ARGS__ = stod(str___);
#define VEC(T, A, n) vector<T> A(n); inp(A);
#define VVEC(T, A, n, m) vector<vector<T>> A(n, vector<T>(m)); inp(A);
// clang-format on

// const value
const ll MOD1   = 1000000007;
const ll MOD9   = 998244353;
const double PI = acos(-1);

// other macro
#if !defined(RIN__LOCAL) && !defined(INTERACTIVE)
#define endl "\n"
#endif
#define spa ' '
#define len(A) ll(A.size())
#define all(A) begin(A), end(A)

// function
vector<char> stoc(string &S) {
    int n = S.size();
    vector<char> ret(n);
    for (int i = 0; i < n; i++) ret[i] = S[i];
    return ret;
}
string ctos(vector<char> &S) {
    int n      = S.size();
    string ret = "";
    for (int i = 0; i < n; i++) ret += S[i];
    return ret;
}

template <class T>
auto min(const T &a) {
    return *min_element(all(a));
}
template <class T>
auto max(const T &a) {
    return *max_element(all(a));
}
template <class T, class S>
auto clamp(T &a, const S &l, const S &r) {
    return (a > r ? r : a < l ? l : a);
}
template <class T, class S>
inline bool chmax(T &a, const S &b) {
    return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
    return (a > b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chclamp(T &a, const S &l, const S &r) {
    auto b = clamp(a, l, r);
    return (a != b ? a = b, 1 : 0);
}

template <typename T>
T sum(vector<T> &A) {
    T tot = 0;
    for (auto a : A) tot += a;
    return tot;
}

template <typename T>
vector<T> compression(vector<T> X) {
    sort(all(X));
    X.erase(unique(all(X)), X.end());
    return X;
}

// input and output
namespace io {
// __int128_t
std::istream &operator>>(std::istream &is, __int128_t &value) {
    std::string str;
    is >> str;
    value    = 0;
    int sign = 1;
    for (size_t i = 0; i < str.size(); i++) {
        if (i == 0 && str[i] == '-') {
            sign = -1;
            continue;
        }
        value = value * 10 + str[i] - '0';
    }
    value *= sign;
    return is;
}

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char *d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) {
            --d;
            *d = '-';
        }
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}

// vector<T>
template <typename T>
istream &operator>>(istream &is, vector<T> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << ' ';
    }
    return os;
}

// vector<vector<T>>
template <typename T>
istream &operator>>(istream &is, vector<vector<T>> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<vector<T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// pair<S, T>
template <typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &A) {
    is >> A.first >> A.second;
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, pair<S, T> &A) {
    os << A.first << ' ' << A.second;
    return os;
}

// vector<pair<S, T>>
template <typename S, typename T>
istream &operator>>(istream &is, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        is >> A[i];
    }
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// tuple
template <typename T, size_t N>
struct TuplePrint {
    static ostream &print(ostream &os, const T &t) {
        TuplePrint<T, N - 1>::print(os, t);
        os << ' ' << get<N - 1>(t);
        return os;
    }
};
template <typename T>
struct TuplePrint<T, 1> {
    static ostream &print(ostream &os, const T &t) {
        os << get<0>(t);
        return os;
    }
};
template <typename... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
    TuplePrint<decltype(t), sizeof...(Args)>::print(os, t);
    return os;
}

// io functions
void FLUSH() {
    cout << flush;
}

void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
    cout << head;
    if (sizeof...(Tail)) cout << spa;
    print(std::forward<Tail>(tail)...);
}

template <typename T, typename S>
void prisep(vector<T> &A, S sep) {
    int n = A.size();
    for (int i = 0; i < n; i++) {
        cout << A[i];
        if (i != n - 1) cout << sep;
    }
    cout << endl;
}
template <typename T, typename S>
void priend(T A, S end) {
    cout << A << end;
}
template <typename T>
void prispa(T A) {
    priend(A, spa);
}
template <typename T, typename S>
bool printif(bool f, T A, S B) {
    if (f)
        print(A);
    else
        print(B);
    return f;
}

template <class... T>
void inp(T &...a) {
    (cin >> ... >> a);
}

} // namespace io
using namespace io;

// read graph
vector<vector<int>> read_edges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<int>> edges(n, vector<int>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        u -= indexed;
        v -= indexed;
        edges[u].push_back(v);
        if (!direct) edges[v].push_back(u);
    }
    return edges;
}
vector<vector<int>> read_tree(int n, int indexed = 1) {
    return read_edges(n, n - 1, false, indexed);
}

template <typename T = long long>
vector<vector<pair<int, T>>> read_wedges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<pair<int, T>>> edges(n, vector<pair<int, T>>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        T w;
        inp(w);
        u -= indexed;
        v -= indexed;
        edges[u].push_back({v, w});
        if (!direct) edges[v].push_back({u, w});
    }
    return edges;
}
template <typename T = long long>
vector<vector<pair<int, T>>> read_wtree(int n, int indexed = 1) {
    return read_wedges<T>(n, n - 1, false, indexed);
}

// yes / no
namespace yesno {

// yes
inline bool yes(bool f = true) {
    cout << (f ? "yes" : "no") << endl;
    return f;
}
inline bool Yes(bool f = true) {
    cout << (f ? "Yes" : "No") << endl;
    return f;
}
inline bool YES(bool f = true) {
    cout << (f ? "YES" : "NO") << endl;
    return f;
}

// no
inline bool no(bool f = true) {
    cout << (!f ? "yes" : "no") << endl;
    return f;
}
inline bool No(bool f = true) {
    cout << (!f ? "Yes" : "No") << endl;
    return f;
}
inline bool NO(bool f = true) {
    cout << (!f ? "YES" : "NO") << endl;
    return f;
}

// possible
inline bool possible(bool f = true) {
    cout << (f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Possible(bool f = true) {
    cout << (f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool POSSIBLE(bool f = true) {
    cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// impossible
inline bool impossible(bool f = true) {
    cout << (!f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Impossible(bool f = true) {
    cout << (!f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool IMPOSSIBLE(bool f = true) {
    cout << (!f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// Alice Bob
inline bool Alice(bool f = true) {
    cout << (f ? "Alice" : "Bob") << endl;
    return f;
}
inline bool Bob(bool f = true) {
    cout << (f ? "Bob" : "Alice") << endl;
    return f;
}

// Takahashi Aoki
inline bool Takahashi(bool f = true) {
    cout << (f ? "Takahashi" : "Aoki") << endl;
    return f;
}
inline bool Aoki(bool f = true) {
    cout << (f ? "Aoki" : "Takahashi") << endl;
    return f;
}

} // namespace yesno
using namespace yesno;

} // namespace templates
using namespace templates;

void solve() {
    INT(n);
    VEC(ll, A, n);
    ll ma = max(A);
    vec(ll, ans, 0);
    fori(i, n) {
        if (A[i] == ma) ans.push_back(i + 1);
    }
    print(ans);
}

int main() {
#ifndef INTERACTIVE
    std::cin.tie(0)->sync_with_stdio(0);
#endif
    // std::cout << std::fixed << std::setprecision(12);
    int t;
    t = 1;
    std::cin >> t;
    while (t--) solve();
    return 0;
}

// // #pragma GCC target("avx2")
// // #pragma GCC optimize("O3")
// // #pragma GCC optimize("unroll-loops")
// // #define INTERACTIVE
//
// #include "kyopro-cpp/template.hpp"
//
// void solve() {
//     INT(n);
//     VEC(ll, A, n);
//     ll ma = max(A);
//     vec(ll, ans, 0);
//     fori(i, n) {
//         if (A[i] == ma) ans.push_back(i + 1);
//     }
//     print(ans);
// }
//
// int main() {
// #ifndef INTERACTIVE
//     std::cin.tie(0)->sync_with_stdio(0);
// #endif
//     // std::cout << std::fixed << std::setprecision(12);
//     int t;
//     t = 1;
//     std::cin >> t;
//     while (t--) solve();
//     return 0;
// }

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

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3792kb

input:

3
1
5
2
1 3
3
3 3 3

output:

1
2
1 2 3

result:

ok 5 number(s): "1 2 1 2 3"

Test #2:

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

input:

10000
25
25 39 31 40 11 29 9 4 42 32 39 5 21 33 19 50 19 20 7 41 13 45 34 23 7
6
33 14 11 25 24 37
6
50 35 17 42 37 10
11
22 17 45 17 48 29 2 42 19 19 50
91
12 27 3 20 37 39 4 48 4 29 44 37 38 11 39 15 38 28 20 19 50 20 48 28 43 6 19 16 7 10 30 44 9 25 13 9 21 8 3 39 11 10 34 28 23 13 49 44 45 4 23 ...

output:

16
6
1
11
21 70 91
14
17 30
10
14 17
31 70 98
53 66
19
11
7 17
4
71 87
40 79
96
2 38 41 66
2
46
2
1
14 62
47 59 60 66 94
45
1 5 12
1
16
33 45
1
3 45
4 39 62
6
4
37 75
54 92
33 49 76 79
7
2 24 27 32
27 77
10
7 34
41
9
88
68
2 42
2
17 28
6
32
5
12
80
20
23 40
22 24 79
14
24 41 72
40 100
16
7
27 31
27
...

result:

ok 15357 numbers

Test #3:

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

input:

100
5000
999999999 303551520 1000000000 786037778 921116838 18370943 1000000000 970529258 479173332 1000000000 53209554 718571072 993385031 999999998 368646468 1000000000 1000000000 995662164 243419220 795364461 999999999 999999998 1000000000 36965093 750670216 223032304 999999998 242604832 55032693...

output:

3 7 10 16 17 23 34 35 37 39 54 65 72 82 92 107 110 117 118 120 123 126 134 135 146 149 151 161 163 168 180 182 185 188 198 212 222 226 232 233 239 243 253 263 267 268 270 275 278 281 285 297 302 327 329 335 338 347 349 358 362 369 371 373 375 376 379 386 390 392 394 396 397 400 407 408 424 435 447 4...

result:

ok 56835 numbers

Test #4:

score: 0
Accepted
time: 40ms
memory: 9280kb

input:

1
500000
1000000000 261120694 1000000000 992679741 1000000000 1000000000 988746251 1000000000 1000000000 740214363 1000000000 155877906 1000000000 1000000000 1000000000 1000000000 1000000000 826931501 1000000000 313767869 579979378 728984235 1000000000 140465175 405623508 158123859 298122102 1000000...

output:

1 3 5 6 8 9 11 13 14 15 16 17 19 23 28 29 30 31 32 33 34 35 36 38 39 40 41 44 45 47 49 51 53 56 57 58 59 61 63 64 65 66 67 70 74 76 77 81 83 84 90 93 94 96 97 99 100 101 102 103 105 106 107 108 109 110 115 119 120 122 123 124 128 129 132 133 136 138 139 140 141 148 150 151 153 154 156 162 164 165 16...

result:

ok 249989 numbers

Test #5:

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

input:

1000
236
202 452 210 54 103 218 274 328 295 211 81 2 394 129 360 176 294 314 323 312 182 475 372 411 90 156 4 324 214 10 491 104 219 112 472 115 325 235 331 334 116 226 321 135 130 174 392 368 142 343 500 36 245 190 435 108 47 469 325 135 462 397 81 395 148 319 171 106 284 203 299 122 385 176 325 13...

output:

51
391 469 512 695
37
4
239
35
4
103
35
52 83
155
105
384
109 552
71
4 499
63
174
215 533
630
570
423
396
142 149 465 469
39
289
101
173
679
2
90 393
131 433
1
452 584 924
10 124
182
120
14
63
15 55
18
43
290 322
622
106
200
84
203
189 449 550 671
61
31 302 339
132
63
183
144
224 287
288 778
28 86 2...

result:

ok 1523 numbers

Test #6:

score: 0
Accepted
time: 18ms
memory: 3644kb

input:

100
911
820 4346 1857 690 3801 1439 1272 687 3378 3371 1017 2538 2520 4065 2384 2760 2473 3223 3827 3738 487 625 48 3755 4086 1756 557 2677 4650 2539 2447 4388 311 4214 2228 1513 1703 4278 1200 104 2992 1179 1372 1194 1195 2830 2634 4284 614 2047 1603 3991 4275 2840 4777 2606 671 3591 1389 2938 2924...

output:

354
2755
2079
2459
1084
1307
1410 2848
145
891
3455 3500 4808
555
9179
958
1
460 4579
133
970
1160
104
234
8308
2587
250 581
634
2603 2817 2957 6133 7700
3126 6850 6920
2638
1524
676
1322
1012
3553 3802
681
5962
329
171 467
859
1002
2804
3759
86
694 728
1843
2140 4608
3101
1298
1570 4213
110 136
292...

result:

ok 143 numbers

Test #7:

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

input:

10
4383
4053 487 25025 46805 6420 5574 28060 12378 27572 44845 46670 6101 26418 40046 19734 41257 33326 19616 33350 49597 35279 3900 38598 8527 34828 28850 48258 41487 18371 19090 22375 34320 17237 29124 7434 4826 32568 31505 15601 48011 1844 46279 2823 47409 10471 41256 32828 16929 35393 7931 41635...

output:

2520
746
22998 45484
2039
43486
39976 51925 56433
1037 21132
15665 32338
7823 22894
9384

result:

ok 16 numbers

Test #8:

score: 0
Accepted
time: 14ms
memory: 6940kb

input:

1
500000
468822 493486 15375 306714 145638 284569 457513 74333 483118 332396 212507 433668 456487 180766 228577 56982 174577 387274 120636 58978 65740 118703 249039 165655 25408 493073 262724 253708 109845 238485 292708 133433 216827 104777 56130 315100 475012 237338 30385 156566 225797 355547 80137...

output:

94506

result:

ok 1 number(s): "94506"

Test #9:

score: 0
Accepted
time: 38ms
memory: 8108kb

input:

1
500000
1000000000 991782875 242380588 1000000000 391098248 1000000000 868348492 131011556 1000000000 179478604 999999998 522976481 642145713 319972945 205935697 1000000000 1000000000 1000000000 999999999 406557979 133373300 1000000000 999999999 232756715 707376167 100310206 1000000000 999999998 99...

output:

1 4 6 9 16 17 18 22 27 44 48 49 60 64 65 69 75 83 97 99 103 115 124 125 126 130 137 142 148 150 155 161 163 172 181 182 186 187 191 195 196 203 214 218 253 264 270 277 284 287 304 308 314 317 335 344 346 355 358 365 374 383 384 391 392 397 406 408 411 418 421 427 430 438 442 443 446 447 460 473 481 ...

result:

ok 83696 numbers

Test #10:

score: 0
Accepted
time: 50ms
memory: 12972kb

input:

1
500000
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 10000...

output:

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 101 102 ...

result:

ok 500000 numbers

Test #11:

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

input:

1
500000
1 6 5 1 10 10 5 10 10 10 10 10 3 10 10 10 9 2 10 8 10 10 10 8 9 10 10 10 10 10 9 10 10 10 6 10 10 10 10 1 10 7 5 10 10 10 1 10 10 3 8 2 1 10 10 10 10 10 10 10 4 2 10 8 10 10 10 6 10 5 3 5 4 10 6 10 10 6 4 8 2 4 10 4 8 10 4 6 10 9 6 10 10 9 6 6 6 10 10 10 5 8 10 10 10 10 10 10 10 6 10 3 10 2...

output:

5 6 8 9 10 11 12 14 15 16 19 21 22 23 26 27 28 29 30 32 33 34 36 37 38 39 41 44 45 46 48 49 54 55 56 57 58 59 60 63 65 66 67 69 74 76 77 83 86 89 92 93 98 99 100 103 104 105 106 107 108 109 111 113 116 118 120 122 127 130 132 139 142 143 144 146 147 148 150 151 152 154 157 161 165 166 168 169 171 17...

result:

ok 275093 numbers

Test #12:

score: 0
Accepted
time: 29ms
memory: 3624kb

input:

100000
7
3 1 5 3 3 4 7
4
7 5 5 3
9
3 4 2 3 7 4 7 1 7
1
7
2
5 2
8
7 2 9 2 3 4 1 2
3
9 9 4
5
10 6 4 2 8
6
8 3 10 3 4 4
10
7 10 8 4 3 3 3 3 5 2
10
10 3 8 7 7 7 4 1 10 8
3
5 2 10
10
1 5 9 10 1 2 1 5 1 3
1
8
7
2 6 2 4 7 3 2
7
5 6 3 4 5 5 10
4
4 3 10 9
1
10
4
6 9 5 4
3
4 2 8
1
6
10
4 10 10 7 3 9 9 9 2 1
4...

output:

7
1
5 7 9
1
1
3
1 2
1
3
2
1 9
3
4
1
5
7
3
1
2
3
1
2 3
1
9
1
4
2
2
2
4
2
1 3
2
3
7
2
1 3 4
1
2
1
1
1
1
2
2
1
1
2
1
2
1
1
1 4
1
2
1
5 7 9
1
7
1 2
2
1
1
1
3
2
3
1
6
1
1
1
1
3
3 5 6
5
4
4
1
4
3 4
1 3
2 5
1
1
9 10
1
1 2
1
1
1
1
4
2
1 5
2
1
2
1
2
1
1
7
2
6
2
1
4 6
1
3 4
6
2
5
3
2
10
5 7
1
2
1
9
4 7
2
7
2
...

result:

ok 123265 numbers

Extra Test:

score: 0
Extra Test Passed