답안 #927751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927751 2024-02-15T09:51:53 Z Rifal 자리 배치 (IOI18_seats) C++14
0 / 100
4000 ms 48564 KB
#include "seats.h"
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
std::vector<int> r;
const int N = 1e3 + 4;
const int M = 1e4 + 4;
int arr[N][N];
pair<int,int> where[M];
int h, w;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
  int siz = R.size();
  h = H, w = W;
  for(int i = 0; i < siz; i++) {
    arr[R[i]][C[i]] = i;
    where[i].first = R[i];
    where[i].second = C[i];
  }
}

int swap_seats(int a, int b) {
  int x1 = where[a].first, y1 = where[a].second;
  int x2 = where[b].first, y2 = where[b].second;
  swap(arr[x1][y1],arr[x2][y2]);
  swap(where[a],where[b]);
  long long arr2[h+1][w+1] = {};
  cout << h << ' ' << w << endl;
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      arr2[i][j] = arr[i-1][j-1];
    }
  }
  for(int i = 0; i <= h; i++) {
    for(int j = 0; j <= w; j++) {
      cout << arr2[i][j] <<' ';
    }
    cout << endl;
  }
  
  for(int i = 0; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      arr2[i][j] += arr2[i][j-1];
    }
  }
  for(int j = 0; j <= w; j++) {
    for(int i = 1; i <= h; i++) {
      arr2[i][j] += arr2[i-1][j];
    }
  }
  int ans = 0;
  for(int i1 = 1; i1 <= h; i1++) {
    for(int j1 = 1; j1 <= w; j1++) {
      for(int i2 = 1; i2 <= h; i2++) {
        for(int j2 = 1; j2 <= w; j2++) {
          if(i2 < i1 || j2 < j1) continue;
          long long sum = arr2[i2][j2] - arr2[i1-1][j2] - arr2[i2][j1-1] + arr2[i1-1][j1-1];
          long long num = (i2-i1+1) * (j2-j1+1);
          long long sum2 = num * (num-1ll) /2ll;
          if(sum == sum2) ans++;
        }
      }
    }
  }
  return ans;
}
/*2 3 2
0 0
1 0
1 1
0 1
0 2
1 2
0 5
0 5*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 169 ms 48564 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4059 ms 4988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 3024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -