# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
833579 |
2023-08-22T06:58:28 Z |
vjudge1 |
Exam (eJOI20_exam) |
C++17 |
|
64 ms |
9908 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 100005;
int par[N], sz[N];
bool vis[N];
int n, cnt = 0, input, x;
bool s1 = false, s2, s3, s4 = true;
vector<int> h;
vector<int> t;
int findpar(int a){
if(a == par[a]) return a;
return par[a] = findpar(par[a]);
}
void merge(int a, int b){
a = findpar(a);
b = findpar(b);
if(a == b) return;
par[b] = a;
sz[a] += sz[b];
}
void dfs(int a){
vis[a] = true;
if(a+1 < n){
if(a+1 < n && h[a+1] <= t[0]){
merge(a, a+1);
}
}
if(a-1 >= 0){
if(a-1 >= 0 && h[a-1] <= t[0]){
merge(a, a-1);
}
}
if(a+1 < n){
if(a+1 < n && h[a+1] <= t[0] && !vis[a+1]) dfs(a+1);
}
if(a-1 >= 0){
if(a-1 >= 0 && h[a-1] <= t[0] && !vis[a-1]) dfs(a-1);
}
}
int main(){
cin >> n;
for(int i = 0; i < n; i++){
cin >> input;
h.push_back(input);
}
for(int i = 0; i < n; i++){
cin >> input;
t.push_back(input);
}
for(int i = 0; i < N; i++){
par[i] = i;
sz[i] = 1;
vis[i] = false;
}
s2 = true;
for(int i = 1; i < n; i++){
if(t[i] != t[i-1]) s2 = false;
}
s3 = false;
for(int i = 1; i < n; i++){
if(t[i] <= t[i-1]) s3 = false;
}
if(n <= 10) s1 = true;
if(s1){
}
if(s2 || n == 1){
for(int i = 0; i < n; i++){
if(h[i] == t[0]) dfs(i);
}
for(int i = 0; i < N; i++){
vis[i] = false;
}
for(int i = 0; i < n; i++){
x = findpar(i);
if(vis[x]) continue;
vis[x] = true;
if(sz[x] != 1 || (sz[x] == 1 && h[x] == t[0])){
cnt += sz[x];
}
}
cout << cnt;
return 0;
}
if(s3 || s4){
vector<int> lis;
vector<int>::iterator it;
for(int i = 0; i < n; i++){
it = lower_bound(lis.begin(),lis.end(), t[i]);
if(it == lis.end()){
lis.push_back(t[i]);
}
else{
*it = t[i];
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1108 KB |
Output is correct |
2 |
Correct |
13 ms |
2952 KB |
Output is correct |
3 |
Correct |
39 ms |
5436 KB |
Output is correct |
4 |
Correct |
28 ms |
9908 KB |
Output is correct |
5 |
Correct |
64 ms |
9036 KB |
Output is correct |
6 |
Correct |
25 ms |
2080 KB |
Output is correct |
7 |
Correct |
31 ms |
9796 KB |
Output is correct |
8 |
Correct |
56 ms |
2032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |