답안 #1095770

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1095770 2024-10-03T07:03:15 Z ezzzay Tracks in the Snow (BOI13_tracks) C++14
30.2083 / 100
2000 ms 1048576 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ff first
#define ss second
#define pb push_back
const int N=3e5;
char a[5005][5005];
bool vis[5005][5005];
int xx[4]={1,-1,0,0};
int yy[4]={0,0,1,-1};
pair<int,int>par[5005][5005];
int lvl[5005][5055];
bool lvlvis[500055];
signed main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)cin>>a[i][j];
    }
    queue<pair<int,int>>q,hq;
    hq.push({n,m});
    int p=0;
    while(!(q.empty() and hq.empty())){
        int y,x;
        if(!q.empty()){
            y=q.front().ff,x=q.front().ss;
            q.pop();
        }
        else{
            
            while(!hq.empty()){
                y=hq.front().ff,x=hq.front().ss;
                hq.pop();

                if(vis[y][x]==0){
                    int py=par[y][x].ff,px=par[y][x].ss;
                    if(lvlvis[lvl[py][px]]==0)p++;
                    lvlvis[lvl[py][px]]=1;
                    break;
                }
                
            }
            if(vis[y][x])continue;
            
        }
        if(y==0 or x==0)continue;
        vis[y][x]=1;
        lvl[y][x]=p;
        char c=a[y][x];
        for(int i=0;i<4;i++){
            if(vis[y+yy[i]][x+xx[i]]==0){
                if(a[y+yy[i]][x+xx[i]]==c){
                    q.push({y+yy[i],x+xx[i]});
                }
                else if(a[y+yy[i]][x+xx[i]]=='F' or a[y+yy[i]][x+xx[i]]=='R'){
                    par[y+yy[i]][x+xx[i]]={y,x};
                    hq.push({y+yy[i],x+xx[i]});
                }
            }
        }
    }
    cout<<p;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1435 ms 1048576 KB Execution killed with signal 9
2 Correct 1 ms 600 KB Output is correct
3 Correct 10 ms 4444 KB Output is correct
4 Runtime error 1675 ms 1048576 KB Execution killed with signal 9
5 Execution timed out 2105 ms 861312 KB Time limit exceeded
6 Correct 1 ms 600 KB Output is correct
7 Correct 9 ms 4444 KB Output is correct
8 Runtime error 1479 ms 1048576 KB Execution killed with signal 9
9 Correct 2 ms 2136 KB Output is correct
10 Runtime error 1613 ms 1048576 KB Execution killed with signal 9
11 Runtime error 1632 ms 1048576 KB Execution killed with signal 9
12 Runtime error 1518 ms 1048576 KB Execution killed with signal 9
13 Execution timed out 2090 ms 797364 KB Time limit exceeded
14 Execution timed out 2076 ms 612772 KB Time limit exceeded
15 Runtime error 1547 ms 1048576 KB Execution killed with signal 9
16 Runtime error 1483 ms 1048576 KB Execution killed with signal 9
17 Runtime error 1613 ms 1048576 KB Execution killed with signal 9
18 Runtime error 1642 ms 1048576 KB Execution killed with signal 9
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 57424 KB Output is correct
2 Runtime error 1837 ms 1048576 KB Execution killed with signal 9
3 Incorrect 688 ms 192732 KB Output isn't correct
4 Execution timed out 2074 ms 525888 KB Time limit exceeded
5 Incorrect 404 ms 171348 KB Output isn't correct
6 Runtime error 1861 ms 1048576 KB Execution killed with signal 9
7 Correct 22 ms 59728 KB Output is correct
8 Correct 22 ms 57336 KB Output is correct
9 Correct 307 ms 155456 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 20 ms 56700 KB Output is correct
12 Correct 4 ms 3416 KB Output is correct
13 Runtime error 1702 ms 1048576 KB Execution killed with signal 9
14 Execution timed out 2099 ms 871060 KB Time limit exceeded
15 Correct 54 ms 42580 KB Output is correct
16 Execution timed out 2028 ms 1048576 KB Time limit exceeded
17 Execution timed out 2075 ms 767112 KB Time limit exceeded
18 Incorrect 216 ms 133936 KB Output isn't correct
19 Execution timed out 2072 ms 581756 KB Time limit exceeded
20 Correct 147 ms 62032 KB Output is correct
21 Correct 399 ms 132312 KB Output is correct
22 Incorrect 463 ms 171424 KB Output isn't correct
23 Execution timed out 2062 ms 536236 KB Time limit exceeded
24 Incorrect 386 ms 134940 KB Output isn't correct
25 Incorrect 895 ms 462420 KB Output isn't correct
26 Runtime error 1974 ms 1048576 KB Execution killed with signal 9
27 Execution timed out 2070 ms 1045376 KB Time limit exceeded
28 Runtime error 1848 ms 1048576 KB Execution killed with signal 9
29 Execution timed out 2084 ms 974908 KB Time limit exceeded
30 Execution timed out 2106 ms 1048576 KB Time limit exceeded
31 Runtime error 1743 ms 1048576 KB Execution killed with signal 9
32 Execution timed out 2068 ms 839160 KB Time limit exceeded