Submission #927700

#TimeUsernameProblemLanguageResultExecution timeMemory
927700MrDebooSeats (IOI18_seats)C++17
11 / 100
4035 ms40892 KiB
#include "seats.h"
#include "bits/stdc++.h"
using namespace std;
vector<pair<int,int>>v;
int slv(int in){
    pair<pair<int,int>,pair<int,int>>pr={{v[in].first,v[in].first},{v[in].second,v[in].second}};
    for(int i=in;i>=0;i--){
        pr.first.first=min(pr.first.first,v[i].first);
        pr.first.second=max(pr.first.second,v[i].first);
        pr.second.first=min(pr.second.first,v[i].second);
        pr.second.second=max(pr.second.second,v[i].second);
    }
    return (in+1==(pr.second.second-pr.second.first+1)*(pr.first.second-pr.first.first+1));
}
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
    v.resize(H*W);
    for(int i=0;i<H*W;i++){
        v[i]={R[i],C[i]};
    }
}
int swap_seats(int a, int b){
    int ans=0;
    swap(v[a],v[b]);
    pair<pair<int,int>,pair<int,int>>pr={{v[0].first,v[0].first},{v[0].second,v[0].second}};
    for(int i=0;i<v.size();i++){
        pr.first.first=min(pr.first.first,v[i].first);
        pr.first.second=max(pr.first.second,v[i].first);
        pr.second.first=min(pr.second.first,v[i].second);
        pr.second.second=max(pr.second.second,v[i].second);
        if(i+1==(pr.second.second-pr.second.first+1)*(pr.first.second-pr.first.first+1))ans++;
    }
    return ans;
}

Compilation message (stderr)

seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
#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...