제출 #1105286

#제출 시각아이디문제언어결과실행 시간메모리
1105286thelegendary08자리 배치 (IOI18_seats)C++14
11 / 100
4062 ms43424 KiB
#include "seats.h"
#include<bits/stdc++.h>
#define f0r(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
using namespace std;
vector<pair<int,int>>v;
int h, w;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
	h = H;
	w = W;
	f0r(i, H * W){
		v.pb({R[i], C[i]});
	}
}

int swap_seats(int a, int b) {
	swap(v[a], v[b]);
	pii x = {v[0].first, v[0].first};
	pii y = {v[0].second, v[0].second};
	int ans = 0;
	f0r(i, h*w){
		x.first = min(v[i].first, x.first);
		x.second = max(v[i].first, x.second);
		y.first = min(v[i].second, y.first);
		y.second = max(v[i].second, y.second);
		if((x.second - x.first + 1) * (y.second - y.first + 1) == i+1)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...