제출 #288587

#제출 시각아이디문제언어결과실행 시간메모리
288587dandrozavr자리 배치 (IOI18_seats)C++14
0 / 100
1812 ms44408 KiB
/*
Uruchamiamy samolot zwiadowczy ( + 500% do wzlamaniej )

/▄/  /█/  /◐/  /▐/   /▌/ /▀/ /░/ /  / choose your own style!

***IT'S OUR LONG WAY TO THE OIILLLL***


░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀  ░░░░░░░░███░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░█▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▀██████████████████████████████████████████████████
░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▄████▄████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████
░░░░░░░░░░░░░░░░░░░░░░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█████████▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀  ░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████░░░░░░░░░░░░░░░
*/
//#pragma GCC target("avx2")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")

//#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>
using namespace std;
//#include <ext/pb_ds/detail/standard_policies.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;template <typename T> using ordered_set = tree <T, null_type, less< T >, rb_tree_tag,tree_order_statistics_node_update>;
//namespace fastio {template <class T> ostream &operator<<(ostream &os, const vector<T> &container) {for (auto &u : container)os << u << " ";return os;} template<class T1, class T2> ostream& operator << (ostream& os, const pair<T1, T2>& p) {return os << p.first << " " << p.second;}template <class T> ostream &operator<<(ostream &os, set<T> const& con) {    for (auto &u : con)        os << u << " ";return os;} void pr() {} template <typename T, typename... args> void pr(T x, args... tail) {cout << x << " ";pr(tail...);}} using namespace fastio;
#define pb push_back
#define ll long long
#define ld long double
#define fi first
#define se second
#define F first
#define S second
#define pii pair < int , int >
#define _ <<" "<<
#define TIME 1.0 * clock() / CLOCKS_PER_SEC
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
//#include "combo.h"



constexpr int MAX_N = 2000;
constexpr int MAX_NUM_MOVES = 8000;

const int N = 1000006;
int X1[N], X2[N], Y1[N], Y2[N], ans[N], all;
vector < int > R, C;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
    ::R = R;
    ::C = C;
    int n = H;
    int m = W;
//    int a[n][m];
    int x1, x2;
    x1 = x2 = R[0];
    int y1, y2;
    y1 = y2 = C[0];
    all = C.size();
    for (int i = 0; i < C.size(); ++i){
//        a[R[i]][C[i]] = i;
        x1 = min(x1, R[i]);
        y1 = min(y1, C[i]);
        x2 = max(x2, R[i]);
        y2 = max(y2, C[i]);
        if (i)
            ans[i] += ans[i - 1];
        if ((x2 - x1 + 1) * (y2 - y1 + 1) == i + 1) ++ans[i];
        X1[i] = x1;
        X2[i] = x2;
        Y1[i] = y1;
        Y2[i] = y2;
//        cout << x1 _ y1 _ x2 _ y2 << endl;
    }
    ans[all] = ans[all - 1];
}

int swap_seats(int a, int b){
    if (a == b) return ans[all];
    swap(R[a], R[b]);
    swap(C[a], C[b]);
    int suf = ans[all] - ans[b];
    int x1 = 2e9, x2 = -2e9, y1 = 2e9, y2 = -2e9;
    if (a){
        x1 = X1[a - 1];
        x2 = X2[a - 1];
        y1 = Y1[a - 1];
        y2 = Y2[a - 1];
    }
    int now = 0;
    if (a) now = ans[a - 1];
    for (int i = a; i < all; ++i){
        x1 = min(x1, R[i]);
        x2 = max(x2, R[i]);
        y1 = min(y1, C[i]);
        y2 = max(y2, C[i]);
        if (x1 == X1[i] && y1 == Y1[i] && x2 == X2[i] && y2 == Y2[i]){
            int dif = now - ans[i];
            for (int j = i; j <= all; ++j)
                ans[j] += dif;
            break;
        }
        X1[i] = x1;
        X2[i] = x2;
        Y1[i] = y1;
        Y2[i] = y2;
//        cout << x1 _ y1 _ x2 _ y2 << endl;
        if ((x2 - x1 + 1) * (y2 - y1 + 1) == i + 1) ++now;
        ans[i] = now;
    }
//    exit(0);
    return ans[all];
}

#ifdef Estb_probitie
int read_int() {
  int x;
  if (scanf("%d", &x) != 1) {
    fprintf(stderr, "Error while reading input\n");
    exit(1);
  }
  return x;
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  int H = read_int();
  int W = read_int();
  int Q = read_int();
  std::vector<int> R(H * W), C(H * W);
  for (int i = 0; i < H * W; ++i) {
    R[i] = read_int();
    C[i] = read_int();
  }
  std::vector<int> A(Q), B(Q);
  for (int j = 0; j < Q; ++j) {
    A[j] = read_int();
    B[j] = read_int();
  }

  give_initial_chart(H, W, R, C);
  for (int j = 0; j < Q; ++j) {
    int answer = swap_seats(A[j], B[j]);
    printf("%d\n", answer);
  }
  return 0;
}
#endif

컴파일 시 표준 에러 (stderr) 메시지

seats.cpp: In function 'void give_initial_chart(int, int, std::vector<int>, std::vector<int>)':
seats.cpp:79:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     for (int i = 0; i < C.size(); ++i){
      |                     ~~^~~~~~~~~~
seats.cpp:71:9: warning: unused variable 'n' [-Wunused-variable]
   71 |     int n = H;
      |         ^
seats.cpp:72:9: warning: unused variable 'm' [-Wunused-variable]
   72 |     int m = W;
      |         ^
seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:101:9: warning: unused variable 'suf' [-Wunused-variable]
  101 |     int suf = ans[all] - ans[b];
      |         ^~~
#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...