| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 487616 | KazamaHoang | Poklon (COCI17_poklon7) | C++14 | 382 ms | 26416 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
void maximize(vector<int>& ans, vector<int>& res) {
    for (int i = 0; i < (int)min(ans.size(), res.size()); ++ i) {
        if (ans[i] != res[i]) {
            if (ans[i] < res[i]) {
                swap(ans, res);
                return;
            }
            if (ans[i] > res[i]) return;
        } 
    }
    if (ans.size() < res.size()) swap(ans, res);
}
int n;
pair<int, int> scale[1000005];
vector<int> ans;
int tmp[30];
void update(int u, int d, int cnt = 0) {
    for (int i = 29; i >= 0; -- i) if ((u >> i) & 1) 
        tmp[++cnt] = i+d;
    vector<int> res(tmp+1, tmp+1+cnt);
    maximize(ans, res);
}
inline void calc() {
    stack<pair<int, int>> st;
    st.push({1, 1});
    while (!st.empty()) {
        int u = st.top().first;
        int d = st.top().second;
        st.pop();
        if (scale[u].first > 0) 
            st.push({scale[u].first, d + 1});
        else update(-scale[u].first, d);
        if (scale[u].second > 0)
            st.push({scale[u].second, d + 1});
        else update(-scale[u].second, d);
    }
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; ++ i) 
        cin >> scale[i].first 
            >> scale[i].second;
    calc();
    ans.push_back(-1);
    for (int j = 0; j + 1 < (int)ans.size(); ++ j) {
        cout << 1;
        for (int h = ans[j] - 1; h > ans[j+1]; -- h) cout << 0;
    }
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
