Submission #1352707

#TimeUsernameProblemLanguageResultExecution timeMemory
1352707nathlol2Seats (IOI18_seats)C++20
5 / 100
4094 ms15920 KiB
#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m, tb[N][N];

void give_initial_chart(int H, int W, vector<int> R, vector<int> C){
  n = H, m = W;
  for(int i = 0;i<n * m;i++){
    tb[R[i]][C[i]] = i;
  }
}

int swap_seats(int a, int b){
  pair<int, int> pa, pb;
  for(int i = 0;i<n;i++){
    for(int j = 0;j<m;j++){
      if(tb[i][j] == a) pa = {i, j};
      if(tb[i][j] == b) pb = {i, j};
    }
  }
  swap(tb[pa.first][pa.second], tb[pb.first][pb.second]);
  int ans = 0;
  for(int i = 0;i<n;i++){
    for(int j = 0;j<m;j++){
      for(int k = i;k<n;k++){
        for(int l = j;l<m;l++){
          bool ok = 1;
          for(int g = i;g<=k;g++){
            for(int f = j;f<=l;f++){
              if(tb[g][f] >= (k - i + 1) * (l - j + 1)){
                ok = 0;
                break;
              }
            }
            if(!ok) break;
          }
          if(ok) ++ans;
        }
      }
    }
  }
  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...