제출 #368082

#제출 시각아이디문제언어결과실행 시간메모리
368082R3KTTracks in the Snow (BOI13_tracks)Java
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <queue> #include <array> using namespace std; typedef long long ll; const int MaxN = 4e3; int h, w; int arr[MaxN][MaxN], visited[MaxN][MaxN]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> h >> w; for (int i=0; i<h; i++) { for (int j=0; j<w; j++) { char cur; cin >> cur; if (cur == 'F') arr[i][j] = 0; else if (cur == 'R') arr[i][j] = 1; else arr[i][j] = -1; } } // for (int i=0; i<h; i++) { // for (int j=0; j<w; j++) { // cout << visited[i][j] << " "; // } // cout << "\n"; // } using T = pair<int, pair<int, pair<int, int>>>; // count, type (0 = fox), x, y priority_queue<T, vector<T>, greater<T>> pq; pq.push({1,{arr[0][0],{0,0}}}); int ans=0; while (!pq.empty()) { T cur = pq.top(); pq.pop(); int count = cur.first; int type = cur.second.first; int x = cur.second.second.first; int y = cur.second.second.second; // if (x < 0 || y < 0 || x >= h || y >= w) continue; // if (arr[x][y] == -1) continue; if (arr[x][y] != type) { count++; } if (visited[x][y] != 0 && visited[x][y] <= count) continue; visited[x][y] = count; ans = max(ans, count); // cout << count << " " << type << " " << x << " " << y << " " << ans << "\n"; if (x+1 >= 0 && y >= 0 && x+1 < h && y < w && arr[x+1][y] != -1) { pq.push({count, {arr[x][y], {x+1, y}}}); } if (x-1 >= 0 && y >= 0 && x-1 < h && y < w && arr[x-1][y] != -1) { pq.push({count, {arr[x][y], {x-1, y}}}); } if (x >= 0 && y+1 >= 0 && x < h && y+1 < w && arr[x][y+1] != -1) { pq.push({count, {arr[x][y], {x, y+1}}}); } if (x >= 0 && y-1 >= 0 && x < h && y-1 < w && arr[x][y-1] != -1) { pq.push({count, {arr[x][y], {x, y-1}}}); } } cout << ans; }

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

tracks.java:1: error: illegal character: '#'
#include <iostream>
^
tracks.java:1: error: class, interface, or enum expected
#include <iostream>
         ^
tracks.java:2: error: illegal character: '#'
#include <vector>
^
tracks.java:3: error: illegal character: '#'
#include <queue>
^
tracks.java:4: error: illegal character: '#'
#include <array>
^
tracks.java:6: error: class, interface, or enum expected
typedef long long ll;
^
tracks.java:8: error: class, interface, or enum expected
const int MaxN = 4e3;
^
tracks.java:9: error: class, interface, or enum expected
int h, w;
^
tracks.java:10: error: class, interface, or enum expected
int arr[MaxN][MaxN], visited[MaxN][MaxN];
^
tracks.java:12: error: class, interface, or enum expected
int main() {
^
tracks.java:14: error: class, interface, or enum expected
    cin.tie(0);
    ^
tracks.java:16: error: class, interface, or enum expected
    cin >> h >> w;
    ^
tracks.java:17: error: class, interface, or enum expected
    for (int i=0; i<h; i++) {
    ^
tracks.java:17: error: class, interface, or enum expected
    for (int i=0; i<h; i++) {
                  ^
tracks.java:17: error: class, interface, or enum expected
    for (int i=0; i<h; i++) {
                       ^
tracks.java:18: error: class, interface, or enum expected
        for (int j=0; j<w; j++) {
                      ^
tracks.java:18: error: class, interface, or enum expected
        for (int j=0; j<w; j++) {
                           ^
tracks.java:20: error: class, interface, or enum expected
            cin >> cur;
            ^
tracks.java:21: error: class, interface, or enum expected
            if (cur == 'F') arr[i][j] = 0;
            ^
tracks.java:22: error: class, interface, or enum expected
            else if (cur == 'R') arr[i][j] = 1;
            ^
tracks.java:23: error: class, interface, or enum expected
            else arr[i][j] = -1;
            ^
tracks.java:24: error: class, interface, or enum expected
        }
        ^
tracks.java:36: error: class, interface, or enum expected
    priority_queue<T, vector<T>, greater<T>> pq;
    ^
tracks.java:37: error: class, interface, or enum expected
    pq.push({1,{arr[0][0],{0,0}}});
    ^
tracks.java:38: error: class, interface, or enum expected
    int ans=0;
    ^
tracks.java:39: error: class, interface, or enum expected
    while (!pq.empty()) {
    ^
tracks.java:41: error: class, interface, or enum expected
        pq.pop();
        ^
tracks.java:42: error: class, interface, or enum expected
        int count = cur.first; int type = cur.second.first; int x = cur.second.second.first; int y = cur.second.second.second;
        ^
tracks.java:42: error: class, interface, or enum expected
        int count = cur.first; int type = cur.second.first; int x = cur.second.second.first; int y = cur.second.second.second;
                               ^
tracks.java:42: error: class, interface, or enum expected
        int count = cur.first; int type = cur.second.first; int x = cur.second.second.first; int y = cur.second.second.second;
                                                            ^
tracks.java:42: error: class, interface, or enum expected
        int count = cur.first; int type = cur.second.first; int x = cur.second.second.first; int y = cur.second.second.second;
                                                                                             ^
tracks.java:45: error: class, interface, or enum expected
        if (arr[x][y] != type) {
        ^
tracks.java:47: error: class, interface, or enum expected
        }
        ^
tracks.java:49: error: class, interface, or enum expected
        visited[x][y] = count;
        ^
tracks.java:50: error: class, interface, or enum expected
        ans = max(ans, count);
        ^
tracks.java:52: error: class, interface, or enum expected
        if (x+1 >= 0 && y >= 0 && x+1 < h && y < w && arr[x+1][y] != -1) {
        ^
tracks.java:54: error: class, interface, or enum expected
        }
        ^
tracks.java:57: error: class, interface, or enum expected
        }
        ^
tracks.java:60: error: class, interface, or enum expected
        }
        ^
tracks.java:63: error: class, interface, or enum expected
        }
        ^
tracks.java:67: error: class, interface, or enum expected
}
^
41 errors