Submission #1553806


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
int H, W, K;
int MAP[1000][1000];
int x, y, vis[1000][1000];
int ans = 2147483647;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
struct PR {
    int x, y, now;
    PR() {x = y = now = 0;}
    PR(int _x, int _y, int _now) {x = _x, y = _y, now = _now;}
};
bool check(int x, int y) {
    if (x < 0 || x > H) return 0;
    if (y < 0 || y > W) return 0;
    if (MAP[x][y]) return 0;
    return 1;
}
int main() {
    cin >> H >> W >> K;
    for (int i = 1; i <= H; i ++) {
        string s;
        cin >> s;
        for (int j = 1; j <= W; j ++) {
            if (s[j - 1] == '#') MAP[i][j] = 1;
            else {
                MAP[i][j] = 0;
                if (s[j - 1] == 'S') x = i, y = j; 
            }
        }
    }
    queue<PR> Q; Q.push((PR){x, y, 0});
    while (!Q.empty()) {
        PR tmp = Q.front(); Q.pop();
        if (tmp.now > K) continue;
        if (vis[tmp.x][tmp.y] <= tmp.now && vis[tmp.x][tmp.y] != 0) continue;
        vis[tmp.x][tmp.y] = tmp.now;
		int num = min(min(H - tmp.x, W - tmp.y), min(tmp.x - 1, tmp.y - 1));
		tmp = (tmp + K - 1) / K;
		if (tmp + 1 > ans) continue;
		ans = min(ans, tmp + 1);
        for (int i = 0; i < 4; i ++) {
            if (check(tmp.x + dx[i], tmp.y + dy[i])) Q.push((PR){tmp.x + dx[i], tmp.y + dy[i], tmp.now + 1});
        }
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task C - Closed Rooms
User xc01
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1449 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:40:14: error: no match for ‘operator+’ (operand types are ‘PR’ and ‘int’)
   tmp = (tmp + K - 1) / K;
              ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:341:5: note: candidate: template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)
     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
     ^
/usr/include/c++/5/bits/stl_iter...