Submission #1111550

#TimeUsernameProblemLanguageResultExecution timeMemory
1111550SalihSahinSeats (IOI18_seats)C++14
0 / 100
4062 ms23872 KiB
#include <bits/stdc++.h>
#define pb push_back
#include "seats.h"
using namespace std;
 
vector<pair<int, int> > pos;
 
void give_initial_chart(int H, int W, vector<int> R, vector<int> C){
  pos.resize(H * W);
 
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      pos[R[i * W + j] * W + C[i * W + j]] = {i, j};
    }
  }
}
 
int swap_seats(int a, int b) {
  swap(pos[a], pos[b]);
 
  int mnx = pos.size(), mxx = 0, mny = pos.size(), mxy = 0;
  int ans = 0;
  for(int i = 0; i < pos.size(); i++){
    mnx = min(mnx, pos[i].second);
    mxx = max(mxx, pos[i].second);
    mny = min(mny, pos[i].first);
    mxy = max(mxy, pos[i].first);
 
    if((mxx - mnx + 1) * (mxy - mny + 1) == (i + 1)){
      ans++;
    }
  }
 
  return ans;
}

Compilation message (stderr)

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