Submission #1208369

#TimeUsernameProblemLanguageResultExecution timeMemory
1208369AvianshSeats (IOI18_seats)C++20
11 / 100
4091 ms39732 KiB
#include "seats.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> r;
vector<int> c;
vector<int>prefmnr;
vector<int>prefmxr;
vector<int>prefmnc;
vector<int>prefmxc;
int ans;

void give_initial_chart(int h, int w, vector<int> R, vector<int> C) {
    r = R;
    c = C;
    prefmnr = vector<int>(h*w);
    prefmxr = vector<int>(h*w);
    prefmnc = vector<int>(h*w);
    prefmxc = vector<int>(h*w);
    ans=0;
    int mnr = r[0];
    int mxr = r[0];
    int mnc = c[0];
    int mxc = c[0];
    for(int i = 0;i<h*w;i++){
        mnr=min(mnr,r[i]);
        mxr=max(mxr,r[i]);
        mnc=min(mnc,c[i]);
        mxc=max(mxc,c[i]);
        bool val = ((i+1)==((mxr-mnr+1)*(mxc-mnc+1)));
        ans+=val;
        prefmnr[i]=mnr;
        prefmxr[i]=mxr;
        prefmnc[i]=mnc;
        prefmxc[i]=mxc;
    }
}

int swap_seats(int a, int b) {
    swap(r[a],r[b]);
    swap(c[a],c[b]);
    ans=0;
    int mnr = r[0];
    int mxr = r[0];
    int mnc = c[0];
    int mxc = c[0];
    for(int i = 0;i<r.size();i++){
        mnr=min(mnr,r[i]);
        mxr=max(mxr,r[i]);
        mnc=min(mnc,c[i]);
        mxc=max(mxc,c[i]);
        bool val = ((i+1)==((mxr-mnr+1)*(mxc-mnc+1)));
        ans+=val;
        prefmnr[i]=mnr;
        prefmxr[i]=mxr;
        prefmnc[i]=mnc;
        prefmxc[i]=mxc;
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...