답안 #1061967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061967 2024-08-16T16:07:14 Z sikai004 Tracks in the Snow (BOI13_tracks) C++14
89.0625 / 100
2000 ms 104884 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int row, col;
    cin>>row>>col;
    char meadow[row][col];
    int vis[row][col];
    for(int i=0;i<row;i++){
        fill(vis[i],vis[i]+col,0);
    }
    for(int i=0;i<row;i++){
        for(int j=0;j<col;j++){
            cin>>meadow[i][j];
        }
    }
    int numberoftimes=0;
    if(meadow[0][0]=='.')return 0;
    int dx[4] = {0, 0, -1, 1},dy[4] = {1, -1, 0, 0};          //dx and dy stores the way to get to the adjacent nodes

    vis[0][0]=1;
    int maxweight=-1;
    priority_queue<tuple<int, int, int>, vector<tuple<int, int, int> >, greater<tuple<int, int, int> > > q; 
                     //pair contains <y_coord, x_coord>
    q.push(make_tuple(1,0, 0));    //push the starting node
    while (!q.empty()) {
        int weight=get<0>(q.top());
        maxweight=max(maxweight,weight);
        int y = get<1>(q.top());
        int x = get<2>(q.top());

        q.pop();
        for (int i = 0; i < 4; i++) {
            int new_y = y + dy[i], new_x = x + dx[i];              //adjacent nodes
            if(new_y>=0 and new_y<row and new_x>=0 and new_x<col and (meadow[new_y][new_x]=='F' or meadow[new_y][new_x]=='R') and vis[new_y][new_x]==0){
                if(meadow[new_y][new_x]==meadow[y][x]){
                    vis[new_y][new_x]=vis[y][x];
                }
                else{
                    vis[new_y][new_x]=vis[y][x]+1;
                }
                q.push(make_tuple(vis[new_y][new_x],new_y,new_x));
            }
            //check if new node is within bounds, not visited and reachable (code for if it is not)
        }

        //cout<<"y: "<<y<<" x: "<<x<<" vis: "<<vis[y][x]<<" currchar: "<<currchar<<" number: "<<number<<"\n";
        
    }
    /*
    for(int i=0;i<row;i++){
        for(int j=0;j<col;j++){
            cout<<vis[i][j]<<" ";
        }
        cout<<"\n";
    }
    */

    cout<<maxweight;
    
}        
        
    

    /*
    for(int i=0;i<row;i++){
        for(int j=0;j<col;j++){
            cout<<vis[i][j]<<" ";
        }
        cout<<"\n";
    }
    */
    //cout<<numberoftimes;

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:18:9: warning: unused variable 'numberoftimes' [-Wunused-variable]
   18 |     int numberoftimes=0;
      |         ^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 1624 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 21 ms 1372 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 784 KB Output is correct
11 Correct 5 ms 604 KB Output is correct
12 Correct 15 ms 968 KB Output is correct
13 Correct 4 ms 860 KB Output is correct
14 Correct 3 ms 860 KB Output is correct
15 Correct 27 ms 1764 KB Output is correct
16 Correct 46 ms 1624 KB Output is correct
17 Correct 17 ms 1660 KB Output is correct
18 Correct 21 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 114 ms 8028 KB Output is correct
3 Correct 430 ms 78556 KB Output is correct
4 Correct 111 ms 18780 KB Output is correct
5 Correct 168 ms 44460 KB Output is correct
6 Execution timed out 2021 ms 104212 KB Time limit exceeded
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 4 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 97 ms 8152 KB Output is correct
14 Correct 56 ms 4700 KB Output is correct
15 Correct 17 ms 5212 KB Output is correct
16 Correct 51 ms 3420 KB Output is correct
17 Correct 259 ms 20308 KB Output is correct
18 Correct 70 ms 19800 KB Output is correct
19 Correct 108 ms 18812 KB Output is correct
20 Correct 96 ms 17280 KB Output is correct
21 Correct 278 ms 45912 KB Output is correct
22 Correct 174 ms 44376 KB Output is correct
23 Correct 515 ms 38236 KB Output is correct
24 Correct 156 ms 44892 KB Output is correct
25 Correct 327 ms 78708 KB Output is correct
26 Correct 955 ms 60452 KB Output is correct
27 Execution timed out 2052 ms 83136 KB Time limit exceeded
28 Execution timed out 2056 ms 104884 KB Time limit exceeded
29 Execution timed out 2080 ms 92852 KB Time limit exceeded
30 Execution timed out 2049 ms 91056 KB Time limit exceeded
31 Correct 1738 ms 51344 KB Output is correct
32 Correct 1754 ms 80324 KB Output is correct