# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
92204 | updown1 | Uzastopni (COCI15_uzastopni) | C++17 | 1088 ms | 33792 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, a, b) for(int i=a; i<b; i++)
#define ffi For(i, 0, MAXV)
#define ffj For(j, 0, MAXV)
#define ffa ffi ffj
#define s <<" "<<
#define c <<" : "<<
#define w cout
#define e endl//"\n"
#define pb push_back
#define mp make_pair
#define a first
#define b second
//#define int ll
const int MAXN=10000, MAXV = 100;
///500,000,000
int N, joke[MAXN];
bool rng[MAXV][MAXV];
vector<int> adj[MAXN], st[MAXN], en[MAXN];
void go(int at) {
for (int i: adj[at]) go(i);
ffa rng[i][j] = false;
for (int i: adj[at]) for (int j: st[i]) for (int k: en[i]) if ( k < joke[at] || joke[at] < j ) rng[j][k] = true;
rng[joke[at]][joke[at]] = true;
For (k, 0, MAXV-1) For (i, 0, k+1) For (j, k+1, MAXV) if (rng[i][k] && rng[k+1][j]) rng[i][j] = true;
//w<< at+1<<e; For (i, 0, 4) {For (j, 0, 4) w<< rng[i][j] << " "; w<<e;}
bool addst[MAXN], adden[MAXN];
ffi addst[i] = adden[i] = false;
ffi For (j, i, MAXV) if (rng[i][j] && i <= joke[at] && joke[at] <= j) {
if (!addst[i]) {st[at].pb(i); addst[i] = true;}
if (!adden[j]) {en[at].pb(j); adden[j] = true;}
}
//w<< at+1<<e; w<< "st:"; for (int i: st[at]) w s i+1; w<<e; w<< "en:"; for (int i: en[at]) w s i+1; w<<e;
}
main() {
//ifstream cin("test.in");
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> N;
For (i, 0, N) {cin >> joke[i]; joke[i]--;}
For (i, 1, N) {int a, b; cin >> a >> b; a--; b--; adj[a].pb(b);}
go(0);
w<< st[0].size()*en[0].size()<<e;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |