QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#876057 | #7690. A Pivotal Question | WeaRD276# | WA | 1ms | 3712kb | C++20 | 1.8kb | 2025-01-30 16:41:34 | 2025-01-30 16:41:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;
int solve()
{
int n;
if (!(cin >> n))
return 1;
vector<int> a(n);
FOR (i, 0, n)
cin >> a[i];
if (n == 1)
{
cout << "1 " << a[0] << '\n';
return 0;
}
vector<int> maxPr(n), minSf(n);
maxPr[0] = a[0];
FOR (i, 1, n)
maxPr[i] = max(maxPr[i - 1], a[i]);
minSf[n - 1] = a[n - 1];
RFOR(i, n - 1, 0)
{
minSf[i] = min(minSf[i + 1], a[i]);
}
vector<int> ans;
FOR (i, 0, n)
{
if (i == 0)
{
if (minSf[1] > a[i])
ans.pb(a[i]);
}
else if (i == n - 1)
{
if (maxPr[n - 2] <= a[i])
ans.pb(a[i]);
}
else
{
if (maxPr[i - 1] <= a[i] && minSf[i + 1] > a[i])
ans.pb(a[i]);
}
}
cout << sz(ans) << ' ';
for (int el: ans)
cout << el << ' ';
cout << '\n';
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cerr << "_____________________________\n";
#endif
}
#ifdef ONPC
cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3712kb
input:
10 1 11 8 13 53 20 63 99 79 94
output:
3 1 13 63
result:
ok single line: '3 1 13 63 '
Test #2:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
3 9 8 7
output:
0
result:
ok single line: '0 '
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
3 7 8 9
output:
3 7 8 9
result:
ok single line: '3 7 8 9 '
Test #4:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
2 1 10
output:
2 1 10
result:
ok single line: '2 1 10 '
Test #5:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
2 10 1
output:
0
result:
ok single line: '0 '
Test #6:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
1 5
output:
1 5
result:
ok single line: '1 5'
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3712kb
input:
1000 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...
output:
1000 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...
result:
wrong answer 1st lines differ - expected: '1000 1 2 3 4 5 6 7 8 9 10 11 1... 91 92 93 94 95 96 97 98 99 100', found: '1000 1 2 3 4 5 6 7 8 9 10 11 1...3 994 995 996 997 998 999 1000 '