제출 #110111

#제출 시각아이디문제언어결과실행 시간메모리
110111SirCeness자리 배치 (IOI18_seats)C++14
11 / 100
4086 ms41040 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; int h, w; vector<int> r, c; void maxi(int& a, int b){ a = max(a, b); } void mini(int& a, int b){ a = min(a, b); } int getans(){ int rmax = r[0]; int rmin = r[0]; int cmax = c[0]; int cmin = c[0]; //cout << rmax << " " << rmin << " - " << cmax << " " << cmin << endl; int ans = 1; for (int i = 1; i < h*w; i++){ maxi(rmax, r[i]); mini(rmin, r[i]); maxi(cmax, c[i]); mini(cmin, c[i]); //cout << rmax << " " << rmin << " - " << cmax << " " << cmin << endl; if ((rmax-rmin+1)*(cmax-cmin+1) == i+1) ans++; } return ans; } void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { h = H; w = W; for (int i = 0; i < h*w; i++){ r.push_back(R[i]); c.push_back(C[i]); } } int swap_seats(int a, int b) { int tmp = r[a]; r[a] = r[b]; r[b] = tmp; tmp = c[a]; c[a] = c[b]; c[b] = tmp; return getans(); }
#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...