Submission #77360

# Submission time Handle Problem Language Result Execution time Memory
77360 2018-09-26T05:27:50 Z Just_Solve_The_Problem Seats (IOI18_seats) C++11
0 / 100
4000 ms 39512 KB
#include <bits/stdc++.h>
#include "seats.h"
// #include "grader.cpp"

#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define OK puts("ok");

using namespace std;

const int N = (int)1e6 + 7;
pair < int, int > pos[N];
int h, w;
int ans;
int was[N];
int mxx[N], mnx[N], mny[N], mxy[N];

void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
  tie(h, w) = make_tuple(H, W);
  h = H;
  w = W;
  for (int i = 0; i < H * W; i++) {
  	pos[i] = mk(R[i], C[i]);
  }
	mnx[0] = mxx[0] = pos[0].fr;
	mny[0] = mxy[0] = pos[0].sc;
	ans = 1;
	was[0] = 1;
	for (int i = 1; i < h * w; i++) {
  	mnx[i] = min(mnx[i - 1], pos[i].fr);
  	mxx[i] = max(mxx[i - 1], pos[i].fr);
  	mny[i] = min(mny[i - 1], pos[i].sc);
  	mxy[i] = max(mxy[i - 1], pos[i].sc);
  	if (i + 1 == (mxx[i] - mnx[i] + 1) * (mxy[i] - mny[i] + 1)) {
  		ans++;
  		was[i] = 1;
  	}
  }                   
}

int swap_seats(int a, int b) {
  swap(pos[a], pos[b]);
  for (int i = a; i <= b; i++) {
  	if (i > 0) {
  		mnx[i] = min(mnx[i - 1], pos[i].fr);
  		mxx[i] = max(mxx[i - 1], pos[i].fr);
  		mny[i] = min(mny[i - 1], pos[i].sc);
  		mxy[i] = max(mxy[i - 1], pos[i].sc);
  	} else {
  		mnx[i] = pos[i].fr;
  		mxx[i] = pos[i].fr;
  		mny[i] = pos[i].sc;
  		mxy[i] = pos[i].sc;  		
  	}
  	if (i + 1 == (mxx[i] - mnx[i] + 1) * (mxy[i] - mny[i] + 1)) {
  		if (!was[i]) {
  			was[i] = 1;
  			ans++;
  		}
  	} else {
  		if (was[i]) {
  			was[i] = 0;
  			ans--;
  		}
  	}
  }
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4030 ms 39512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 39512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 39512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -