Submission #1324770

#TimeUsernameProblemLanguageResultExecution timeMemory
1324770vladiliusGarden (JOI23_garden)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, m, d; cin>>n>>m>>d;
    vector<pii> M[2 * d];
    vector<int> f(d + 2); f[0] = f[d + 1] = 1;
    for (int i = 1; i <= n; i++){
        int x, y; cin>>x>>y;
        y++;
        f[y]++;
        M[x].pb({y, 1});
        M[x + d].pb({y, 1});
    }
    
    vector<int> D[2 * d];
    vector<pii> all;
    for (int i = 1; i <= m; i++){
        int x, y; cin>>x>>y;
        y++;
        M[x].pb({y, 0});
        M[x + d].pb({y, 0});
        all.pb({x, y});
    }
    
    dsu T(d);
    
    ll out = 1e18;
    for (int i = 0; i < d; i++){
        for (auto [x, y]: all){
            f[y]++;
        }

        auto get = [&](){
            int pre = 1e9, mx = 0;
            for (int j = 1; j <= d; j++){
                if (f[j]){
                    mx = max(mx, j - pre);
                    pre = j;
                }
            }
            if (!mx) return d;
            return mx;
        };
        
        int cc = 0;
        for (int j = i; j < i + d; j++){
            for (auto [y, b]: M[j]){
                if (b){
                    cc++;
                }
                else {
                    f[y]--;
                }
            }
            if (cc == n){
                out = min(out, 1LL * (j - i + 1) * ((d + 1) - get()));
            }
        }
    }
    
    cout<<out<<"\n";
}

Compilation message (stderr)

garden.cpp: In function 'int main()':
garden.cpp:35:5: error: 'dsu' was not declared in this scope
   35 |     dsu T(d);
      |     ^~~