답안 #1061981

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061981 2024-08-16T16:15:59 Z sikai004 Tracks in the Snow (BOI13_tracks) C++14
31.7708 / 100
642 ms 78716 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; 
    queue<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.front());
        maxweight=max(maxweight,weight);
        int y = get<1>(q.front());
        int x = get<2>(q.front());

        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 Incorrect 10 ms 1628 KB Output isn't correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 5 ms 1116 KB Output isn't correct
5 Incorrect 2 ms 860 KB Output isn't correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 344 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 1 ms 344 KB Output isn't correct
10 Incorrect 2 ms 772 KB Output isn't correct
11 Incorrect 1 ms 604 KB Output isn't correct
12 Incorrect 4 ms 860 KB Output isn't correct
13 Incorrect 2 ms 860 KB Output isn't correct
14 Incorrect 2 ms 860 KB Output isn't correct
15 Incorrect 10 ms 1628 KB Output isn't correct
16 Incorrect 10 ms 1628 KB Output isn't correct
17 Incorrect 7 ms 1372 KB Output isn't correct
18 Incorrect 5 ms 1116 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Incorrect 42 ms 8092 KB Output isn't correct
3 Incorrect 281 ms 78684 KB Output isn't correct
4 Incorrect 67 ms 18776 KB Output isn't correct
5 Correct 141 ms 44372 KB Output is correct
6 Incorrect 642 ms 78704 KB Output isn't correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Incorrect 2 ms 552 KB Output isn't correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Incorrect 41 ms 8104 KB Output isn't correct
14 Incorrect 24 ms 4864 KB Output isn't correct
15 Correct 16 ms 5212 KB Output is correct
16 Incorrect 25 ms 3420 KB Output isn't correct
17 Incorrect 115 ms 20060 KB Output isn't correct
18 Correct 60 ms 19804 KB Output is correct
19 Incorrect 73 ms 18780 KB Output isn't correct
20 Incorrect 61 ms 17264 KB Output isn't correct
21 Incorrect 158 ms 45984 KB Output isn't correct
22 Correct 166 ms 44380 KB Output is correct
23 Incorrect 216 ms 38320 KB Output isn't correct
24 Correct 145 ms 44892 KB Output is correct
25 Correct 240 ms 78676 KB Output is correct
26 Correct 392 ms 60240 KB Output is correct
27 Incorrect 532 ms 78704 KB Output isn't correct
28 Incorrect 616 ms 78716 KB Output isn't correct
29 Incorrect 617 ms 78528 KB Output isn't correct
30 Incorrect 542 ms 76880 KB Output isn't correct
31 Incorrect 513 ms 50420 KB Output isn't correct
32 Incorrect 481 ms 78684 KB Output isn't correct