Submission #853334

# Submission time Handle Problem Language Result Execution time Memory
853334 2023-09-24T07:25:28 Z aaronkim00 수족관 3 (KOI13_aqua3) C++17
0 / 100
77 ms 20684 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(),v.end()
const ll MOD = 1000000007;

struct FLOOR{
    ll idx, x1, x2, y;
};

vector<int> tree[300010];
ll w[300010];
ll val[300010];

const bool compare(const int x, const int y){
    return val[x]>val[y];
}

int dfs(int u){
    int curr = u;
    for(int v: tree[u]){
        int t = dfs(v);
        if(val[curr] < val[t]){
            curr = t;
        }
    }
    val[curr] += w[u];
    return curr;
}

int main(void){
    int N, K;
    scanf("%d", &N);
    int t1, t2;
    scanf("%d %d", &t1, &t2);
    stack<FLOOR> st;
    st.push({0, 0, 0, -1});
    ll maxX = 0;
    ll minY = 1000000000;
    for(int i=1; i<=N/2; i++){
        ll x1 = maxX, y = -1, x2 = maxX;
        if(i<N/2){
            scanf("%lld %lld", &x1, &y);
            scanf("%lld %lld", &x2, &y);
            minY = min(minY, y);
            maxX = x2;
        }
        while(true){
            FLOOR t = st.top();
            st.pop();
            if(t.y<y){
                st.push(t);
                st.push({i, x1, x2, y});
                break;
            }
            else if(t.y==y){
                st.push(t);
                break;
            }
            else{
                if(st.top().y < y){
                    tree[i].push_back(t.idx);
                }
                else{
                    tree[st.top().idx].push_back(t.idx);
                }
                w[t.idx] = (ll)(t.y-max(st.top().y, y))*(ll)(x1-st.top().x2);
            }
        }
    }
    scanf("%lld %d", &t1, &t2);
    scanf("%d", &K);
    for(int i=1; i<N/2; i++){
        //printf("%lld, %lld\n", w[i], (minY+1)*maxX);
        if(w[i]==(minY+1)*maxX){
            dfs(i);
        }
    }
    /*for(int i=1; i<N/2; i++){
        printf("%d: %d %lld %lld\n", i, parent[i], w[i], val[i]);
        for(int x: tree[i]){
            printf("%d ", x);
        }
        printf("\n");
    }*/
    ll result = 0;
    vector<int> L;
    for(int i=0; i<N/2; i++){
        L.push_back(i);
    }
    sort(all(L), compare);
    for(int i=0; i<K; i++){
        result += val[L[i]];
    }
    printf("%lld\n", result-maxX);
}

Compilation message

aqua3.cpp: In function 'int main()':
aqua3.cpp:71:15: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
   71 |     scanf("%lld %d", &t1, &t2);
      |            ~~~^      ~~~
      |               |      |
      |               |      int*
      |               long long int*
      |            %d
aqua3.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
aqua3.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     scanf("%d %d", &t1, &t2);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
aqua3.cpp:43:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |             scanf("%lld %lld", &x1, &y);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~
aqua3.cpp:44:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |             scanf("%lld %lld", &x2, &y);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~
aqua3.cpp:71:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |     scanf("%lld %d", &t1, &t2);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
aqua3.cpp:72:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |     scanf("%d", &K);
      |     ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 9816 KB Output is correct
2 Correct 2 ms 9820 KB Output is correct
3 Incorrect 2 ms 9820 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 9816 KB Output is correct
2 Correct 4 ms 9816 KB Output is correct
3 Incorrect 5 ms 10076 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 18676 KB Output is correct
2 Correct 63 ms 18580 KB Output is correct
3 Incorrect 69 ms 20568 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 18512 KB Output is correct
2 Correct 63 ms 18504 KB Output is correct
3 Incorrect 70 ms 19404 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 64 ms 18644 KB Output is correct
2 Correct 65 ms 18648 KB Output is correct
3 Incorrect 77 ms 20684 KB Output isn't correct
4 Halted 0 ms 0 KB -