# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
242278 | cheeheng | Magic Tree (CEOI19_magictree) | C++14 | 70 ms | 10104 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<int> AdjList[100005];
int d[100005];
int w[100005];
int L[100005];
int main(){
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
bool subtask3 = true;
for(int i = 2; i <= n; i ++){
int p;
scanf("%d", &p);
subtask3 &= p == i-1;
AdjList[p].push_back(i);
}
bool subtask2 = true;
long long ans2 = 0;
memset(d, -1, sizeof(d));
for(int i = 1; i <= m; i ++){
int x, y, z;
scanf("%d%d%d", &x, &y, &z);
subtask3 &= (z == 1);
subtask2 &= AdjList[x].empty();
d[x] = y;
w[x] = z;
ans2 += w[x];
}
if(subtask2){
printf("%lld", ans2);
return 0;
}
if(subtask3){
int lis = 0;
/*for(int i = n; i >= 2; i --){
printf("%d ", d[i]);
}
printf("\n");*/
for(int i = n; i >= 2; i --){
if(d[i] == -1){continue;}
int pos = lower_bound(L, L+lis, d[i])-L;
L[pos] = d[i];
if(pos == lis){
lis ++;
}
}
printf("%d\n", lis);
return 0;
}else{
throw;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |