Submission #808030

#TimeUsernameProblemLanguageResultExecution timeMemory
808030pravcoderSeats (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...