Submission #28578

# Submission time Handle Problem Language Result Execution time Memory
28578 2017-07-16T07:34:24 Z 볼빨간 승관이(#1152, sys7961, deneb2016, hyorothy) Oriental P.A.D.A.K (FXCUP2_padak) C++11
0 / 1
1000 ms 57728 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <unordered_map>
#include <list>
#include <unordered_set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define INFI 987654321
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
struct Node{
    int x, y, dist;
};
int N, M, K, B, Z;
set<pi> visit;
vector<int> data;
int dx[] = {1, 0, 0, -1};
int dy[] = {0, 1, -1, 0};
int main() {
    ios_base::sync_with_stdio(false);
    cin >> N >> M >> K >> B >> Z;
    queue<Node> que;
    for(int i = 0; i < K; ++i) {
        Node here;
        cin >> here.x >> here.y;
        visit.insert(pi(here.x, here.y));
        here.dist = 0;
        que.push(here);
    }
    while(que.empty() == false) {
        Node here = que.front();
        //cout << here.x << " " << here.y << endl;
        que.pop();
        data.push_back(here.dist);
        for(int i = 0; i < 4; ++i) {
            Node there = here;
            there.x += dx[i];
            there.y += dy[i];
            there.dist++;
            if(there.x < 1 || there.y < 1 || there.x > N || there.y > M)
                continue;
            if(visit.find(pi(there.x, there.y)) == visit.end()) {
                que.push(there);
                visit.insert(pi(there.x, there.y));
            }
        }
    }
    reverse(data.begin(), data.end());
    vector<int> data2 = data;
    int mini = 0, maxi = 0, t = 0, cur = 0;

    while(data.empty() == false) {
        while(data.empty() == false && data.back() <= t)
            data.pop_back();

        for(int i = 0; i < Z; ++i) {
            if(cur >= data.size())
                break;
            mini++;
            cur++;
        }
        t++;
    }
    t = 0;
    while(data2.empty() == false) {
        while(data2.empty() == false && data2.back() <= t)
            data2.pop_back();

        for(int i = 0; i < Z; ++i) {
            if(data2.empty())
                break;
            data2.pop_back();
            maxi++;
        }
        t++;
    }

    cout << mini << " " << maxi;
    return 0;
}

Compilation message

padak.cpp: In function 'int main()':
padak.cpp:66:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(cur >= data.size())
                    ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2184 KB Output is correct
2 Correct 0 ms 2316 KB Output is correct
3 Execution timed out 1000 ms 57728 KB Execution timed out
4 Halted 0 ms 0 KB -