답안 #835475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835475 2023-08-23T14:57:09 Z mousebeaver 자리 배치 (IOI18_seats) C++14
0 / 100
4000 ms 49420 KB
#include "seats.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;

struct inf
{
    int r1;
    int r2;
    int c1;
    int c2;
    bool possible;
};

vector<inf> a(0);
vector<pii> p(0);
int counter = 1;
int n = 0;

void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) 
{
    n = H*W;
    for(int i = 0; i < n; i++)
    {
        p.push_back({R[i], C[i]});
    }

    a = {{p[0].first, p[0].first, p[0].second, p[0].second, true}};
    for(int i = 1; i < n; i++)
    {
        a.push_back(a.back());
        a.back().r1 = min(a.back().r1, p[0].first);
        a.back().r2 = max(a.back().r2, p[i].first);
        a.back().c1 = min(a.back().c1, p[i].second);
        a.back().c2 = max(a.back().c2, p[i].second);
        a.back().possible = ((1+a.back().r2-a.back().r1)*(1+a.back().c2-a.back().c1) == i+1);
        counter += a.back().possible;
    }
}

int swap_seats(int d, int b) 
{
    swap(p[d], p[b]);

    for(int i = 0; i <= n-1; i++)
    {
        counter -= a.back().possible;
        if(i == 0)
        {
            a[i] = {p[0].first, p[0].first, p[0].second, p[0].second, true};
        }
        else
        {
            a[i] = a[i-1];
        }
        a.back().r1 = min(a.back().r1, p[0].first);
        a.back().r2 = max(a.back().r2, p[i].first);
        a.back().c1 = min(a.back().c1, p[i].second);
        a.back().c2 = max(a.back().c2, p[i].second);
        a.back().possible = ((1+a.back().r2-a.back().r1)*(1+a.back().c2-a.back().c1) == i+1);
        counter += a.back().possible;
    }

    return counter;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4011 ms 49420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 219 ms 948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 1276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -