Submission #212708

#TimeUsernameProblemLanguageResultExecution timeMemory
212708MarcoMeijerSeats (IOI18_seats)C++14
11 / 100
4075 ms48632 KiB
#include "seats.h"
#include <bits/stdc++.h>
using namespace std;

//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int h, w, n;
vi r, c;
vii pos;

void give_initial_chart(int H, int W, vi R, vi C) {
	h=H, w=W, r=R, c=C;
	n = h*w;
	pos.resize(n);
	RE(i,n) pos[i] = {r[i], c[i]};
}

int swap_seats(int a, int b) {
	int cnt  =  0;
	int minR =  INF;
	int maxR = -INF;
	int minC =  INF;
	int maxC = -INF;
	swap(pos[a], pos[b]);
	RE(i,n) {
		minR = min(minR, pos[i].fi);
		maxR = max(maxR, pos[i].fi);
		minC = min(minC, pos[i].se);
		maxC = max(maxC, pos[i].se);
		if((maxR-minR+1)*(maxC-minC+1) == i+1) cnt++;
	}
	return cnt;
}
#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...