QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#535815 | #8904. Рекорды и антирекорды | Mispertion# | 0 | 130ms | 70708kb | C++23 | 2.5kb | 2024-08-28 15:15:53 | 2024-08-28 15:15:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define int ll
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define getlast(s) (*s.rbegin())
#define debg cout << "OK\n"
const ld PI = 3.1415926535;
const int N = 200 + 10;
const int M = 1e5 + 10;
int mod = 998244353;
const int infi = INT_MAX;
const ll infl = 1e16;
const int P = 2;
int mult(int a, int b){
return a * 1LL * b % mod;
}
int sum(int a, int b){
if(a + b >= mod)
return a + b - mod;
if(a + b < 0)
return a + b + mod;
return a + b;
}
int binpow(int a, int n){
if (n == 0)
return 1;
if (n % 2 == 1){
return mult(binpow(a, n - 1), a);
}
else{
auto b = binpow(a, n / 2);
return mult(b, b);
}
}
int n, a[N], dp[N][N][N];
void solve(){
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
dp[1][1][0] = 1;
dp[1][0][1] = 1;
int ans = 0;
for(int i = 1; i < n; i++){
for(int as = 0; as <= i; as++){
for(int de = 0; de <= i; de++){
if(as == de) continue;
//i + 1 >> as
int nxt = as, ad = 0;
if(as == 0 || a[i + 1] > a[as])
nxt = i + 1, ad = 1;
dp[i + 1][nxt][de] = max(dp[i + 1][nxt][de], dp[i][as][de] + ad);
//i + 1 >> de
nxt = de, ad = 0;
if(de == 0 || a[i + 1] < a[de])
nxt = i + 1, ad = 1;
dp[i + 1][as][nxt] = max(dp[i + 1][as][nxt], dp[i][as][de] + ad);
}
}
}
for(int i = 0; i <= n; i++){
for(int j = 0; j <= n; j++){
ans = max(ans, dp[n][i][j]);
}
}
for(int i = 0; i <= n; i++)
for(int j = 0; j <= n; j++)
for(int k = 0; k <= n; k++)
dp[i][j][k] = 0;
cout << ans << '\n';
}
signed main(){
mispertion;
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int t = 1;
cin >> t;
while (t--){
solve();
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 21
Accepted
time: 1ms
memory: 3728kb
input:
120 5 3 1 4 2 5 5 3 4 2 5 1 5 5 4 2 1 3 5 1 2 5 4 3 5 2 4 3 1 5 5 3 1 5 2 4 5 1 4 2 3 5 5 5 1 4 3 2 5 1 5 3 2 4 5 3 1 2 5 4 5 3 1 5 4 2 5 1 2 3 4 5 5 1 5 2 4 3 5 3 5 2 1 4 5 2 1 5 4 3 5 1 5 3 4 2 5 3 1 4 5 2 5 2 1 4 5 3 5 1 3 5 4 2 5 5 3 4 2 1 5 2 1 3 5 4 5 2 3 1 5 4 5 2 4 3 5 1 5 4 3 2 5 1 5 4 5 2 ...
output:
5 5 5 5 5 4 5 5 5 4 4 5 5 5 4 5 5 4 5 5 4 4 5 5 4 5 4 5 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 5 4 5 5 5 4 5 5 5 5 4 5 5 5 5 5 5 4 5 5 5 5 5 5 4 5 4 5 5 5 5 4 5 5 4 5 4 5 4 5 5 4 4 4 4 5 5 4 4 5 5 5 4 5 4 5 5 5 4 5 4 5 5 4 4 5 5 5 4 5 5 5 5
result:
ok 120 numbers
Test #2:
score: 0
Wrong Answer
time: 2ms
memory: 4100kb
input:
120 16 11 8 4 12 3 6 10 9 7 15 14 2 16 5 1 13 16 9 1 13 14 3 7 5 15 4 11 2 12 8 6 16 10 16 3 12 11 10 5 13 4 8 9 2 7 16 6 14 15 1 16 9 4 7 2 3 8 1 13 5 12 16 14 11 10 6 15 16 14 5 11 10 6 12 7 9 1 16 15 3 4 8 13 2 16 3 13 16 10 5 11 8 4 15 2 9 7 14 1 6 12 16 4 16 7 11 15 5 9 14 8 13 6 3 1 2 12 10 16...
output:
10 10 12 9 11 10 11 12 10 11 9 10 10 9 12 11 12 10 9 10 10 8 11 10 10 11 11 11 9 11 9 10 11 12 11 12 11 10 13 11 11 11 11 10 10 12 10 10 11 9 10 11 10 11 11 12 12 10 11 11 11 10 9 10 12 10 12 11 11 10 11 11 9 11 11 9 11 11 11 11 10 10 11 11 10 10 12 10 9 12 13 10 9 12 11 10 11 11 11 13 11 10 9 10 11...
result:
wrong answer 34th numbers differ - expected: '11', found: '12'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Runtime Error
Test #49:
score: 13
Accepted
time: 23ms
memory: 4056kb
input:
9000 8 4 1 2 3 5 6 7 8 12 1 2 12 3 4 5 6 7 8 9 10 11 15 4 1 13 2 15 3 5 6 7 8 9 10 11 12 14 15 4 5 10 14 1 2 3 6 7 8 9 11 12 13 15 9 4 1 2 3 5 6 7 8 9 13 1 4 9 12 2 3 5 6 7 8 10 11 13 14 1 10 2 3 4 5 6 7 8 9 11 12 13 14 15 1 6 7 2 3 4 5 8 9 10 11 12 13 14 15 12 1 4 6 10 12 2 3 5 7 8 9 11 8 7 8 1 2 3...
output:
8 12 13 12 9 11 14 14 9 7 12 15 6 13 8 9 8 11 10 5 7 9 11 12 8 6 14 6 6 10 6 9 8 13 6 14 13 5 6 5 9 13 6 12 14 8 4 13 12 8 9 9 11 9 13 6 6 5 11 11 11 6 5 14 13 14 12 6 14 8 8 9 7 9 15 10 7 14 8 11 5 6 8 12 9 8 12 8 9 10 8 6 10 11 10 15 12 11 12 7 8 7 9 7 13 6 12 5 7 9 10 8 13 6 7 8 13 12 10 5 9 10 7...
result:
ok 9000 numbers
Test #50:
score: 13
Accepted
time: 130ms
memory: 4488kb
input:
10000 20 1 9 12 13 17 2 18 19 3 4 5 6 7 8 10 11 14 15 16 20 20 1 2 5 9 17 18 3 4 6 7 8 10 11 12 13 14 15 16 19 20 20 8 9 10 13 1 2 3 4 5 6 7 11 12 14 15 16 17 18 19 20 20 9 10 13 1 2 3 4 5 6 7 8 11 12 14 15 16 17 18 19 20 20 8 1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19 20 20 1 9 13 2 16 3 4 5 6 7...
output:
15 17 17 18 20 18 14 15 17 13 18 17 15 20 19 15 17 18 20 19 18 18 16 16 16 16 19 15 16 18 17 15 18 20 17 20 18 19 19 16 18 14 16 20 18 20 16 19 18 18 17 20 20 16 17 16 17 16 16 19 20 18 19 16 15 19 17 17 18 17 18 20 15 16 16 20 17 18 15 19 17 17 14 17 18 18 17 19 19 18 18 17 19 13 18 18 16 14 16 19 ...
result:
ok 10000 numbers
Test #51:
score: 13
Accepted
time: 15ms
memory: 70708kb
input:
1 200 3 4 1 15 85 2 95 162 5 6 7 8 9 10 11 12 13 14 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 86 87 88 89 90 91 92 93 94 96 97 98 99 10...
output:
196
result:
ok 1 number(s): "196"
Test #52:
score: 0
Runtime Error
input:
10 20000 115 194 264 325 497 569 825 835 955 1036 1174 1292 1382 1436 1440 1580 1642 1845 1968 2013 2092 2214 2274 2400 2573 2763 2791 2809 2838 2891 3127 3239 3240 3296 3447 3602 3765 3903 4009 4095 4133 4200 4237 4368 4573 4590 4692 4714 4825 5028 5073 5380 5457 5479 5497 5730 5884 5896 6001 6316 ...
output:
result:
Subtask #6:
score: 0
Skipped
Dependency #1:
0%