Submission #837919

# Submission time Handle Problem Language Result Execution time Memory
837919 2023-08-25T20:15:08 Z FulopMate Seats (IOI18_seats) C++17
0 / 100
4000 ms 43316 KB
#include "seats.h"
#include <bits/stdc++.h>

using namespace std;

int n;
vector<pair<int,int>> v;
vector<int> a, b, c, d, ans;

void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
    n = H*W;
    v.resize(n);
    a.resize(n); b.resize(n);
    c.resize(n); d.resize(n);
    ans.resize(n);
    for(int i = 0; i < n; i++){
        v[i] = {R[i], C[i]};
    }

    int cans = 1;
    int ca = v[0].first, cb = v[0].first, cc = v[0].second, cd = v[0].second;
    a[0] = ca, b[0] = cb, c[0] = cc, d[0] = cd;
    ans[0] = 1;
    for(int i = 1; i < n; i++){
        ca = min(ca, v[i].first);
        cb = max(cb, v[i].first);
        cc = min(cc, v[i].second);
        cd = max(cd, v[i].second);
        if(i+1 == (cb-ca+1)*(cd-cc+1)){
            cans++;
        }
        a[i] = ca, b[i] = cb, c[i] = cc, d[i] = cd;
        ans[i] = cans;
    }
}

int swap_seats(int x, int y) {
    swap(v[x], v[y]);
    if(x > y)swap(x, y);
    int ca, cb, cc, cd;
    int cans = 0;
    if(x == 0){
        ca = v[0].first; cb = v[0].first;
        cc = v[0].second; cd = v[0].second;
        cans = 0;
    } else {
        ca = a[x-1]; cb = b[x-1];
        cc = c[x-1]; cd = d[x-1];
        cans = ans[x-1];
    }
    for(int i = x; i <= y; i++){
        ca = min(ca, v[i].first);
        cb = max(cb, v[i].first);
        cc = min(cc, v[i].second);
        cd = max(cd, v[i].second);
        if(i+1 == (cb-ca+1)*(cd-cc+1)){
            cans++;
        }
        a[i] = ca, b[i] = cb, c[i] = cc, d[i] = cd;
        ans[i] = cans;
    }
    return cans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4019 ms 43316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 1360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -