# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
833460 |
2023-08-22T05:52:22 Z |
vjudge1 |
Exam (eJOI20_exam) |
C++ |
|
12 ms |
1100 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1005;
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){
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 |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
12 ms |
1100 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |