제출 #808030

#제출 시각아이디문제언어결과실행 시간메모리
808030pravcoder자리 배치 (IOI18_seats)C++17
11 / 100
4073 ms24600 KiB
#include "seats.h" #include <cmath> #include <cstdio> #include <vector> #include <algorithm> using namespace std; typedef vector<int> vi; typedef pair<int, int> pi; typedef vector<pi> vpi; vpi pos; int h, w, n; void give_initial_chart(int H, int W, vi R, vi C) { for (int i = 0; i < H*W; i++) { pos.push_back({ R[i], C[i] }); } h = H, w = W, n = H * W; } int swap_seats(int a, int b) { pi temp = pos[a]; pos[a] = pos[b]; pos[b] = temp; int k = 1; int minc, minr, maxc, maxr; minr = maxr = pos[0].first; minc = maxc = pos[0].second; for (int i = 1; i < n; i++) { minr = min(minr, pos[i].first); maxr = max(maxr, pos[i].first); minc = min(minc, pos[i].second); maxc = max(maxc, pos[i].second); if ((maxc - minc + 1) * (maxr - minr + 1) == i + 1) { k++; } } return k; }
#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...