# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
927184 | 2024-02-14T11:17:31 Z | haru09 | Tracks in the Snow (BOI13_tracks) | C++17 | 538 ms | 132520 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define task "code" const int ar=4e3+5; const ll mod=1e9+7; int m,n; int a[ar][ar]; int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1}; deque<pair<int,int>> qu; bool vs[ar][ar]; int ans=0; void bfs() { qu.push_back({1,1}); vs[1][1]=true; int last=0; while(qu.size()) { pair<int,int> p=qu.front(); qu.pop_front(); int u=p.fi; int v=p.se; if (a[u][v]!=last) ans++; last=a[u][v]; for (int i=0;i<=3;i++) { int x=u+dx[i]; int y=v+dy[i]; if (x<1 || x>m || y<1 || y>n) continue; if (a[x][y]==0) continue; if (vs[x][y]) continue; if (a[x][y]==a[u][v]) { qu.push_front({x,y}); } else qu.push_back({x,y}); vs[x][y]=true; } } cout<<ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); if (fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin>>m>>n; for (int i=1;i<=m;i++) { for (int j=1;j<=n;j++) { char x; cin>>x; if (x=='.') a[i][j]=0; else if (x=='R') a[i][j]=1; else a[i][j]=2; } } bfs(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12888 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2516 KB | Output is correct |
4 | Correct | 7 ms | 13012 KB | Output is correct |
5 | Correct | 3 ms | 7768 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 4700 KB | Output is correct |
9 | Correct | 1 ms | 4956 KB | Output is correct |
10 | Correct | 3 ms | 7516 KB | Output is correct |
11 | Correct | 3 ms | 7260 KB | Output is correct |
12 | Correct | 5 ms | 7736 KB | Output is correct |
13 | Correct | 3 ms | 7772 KB | Output is correct |
14 | Correct | 4 ms | 7772 KB | Output is correct |
15 | Correct | 11 ms | 12892 KB | Output is correct |
16 | Correct | 13 ms | 12892 KB | Output is correct |
17 | Correct | 10 ms | 12636 KB | Output is correct |
18 | Correct | 7 ms | 12892 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 76376 KB | Output is correct |
2 | Correct | 42 ms | 29276 KB | Output is correct |
3 | Correct | 269 ms | 92740 KB | Output is correct |
4 | Correct | 73 ms | 41556 KB | Output is correct |
5 | Correct | 168 ms | 69108 KB | Output is correct |
6 | Correct | 525 ms | 106468 KB | Output is correct |
7 | Correct | 13 ms | 78684 KB | Output is correct |
8 | Correct | 12 ms | 76380 KB | Output is correct |
9 | Correct | 2 ms | 2420 KB | Output is correct |
10 | Correct | 1 ms | 2648 KB | Output is correct |
11 | Correct | 13 ms | 78428 KB | Output is correct |
12 | Correct | 1 ms | 4956 KB | Output is correct |
13 | Correct | 42 ms | 29268 KB | Output is correct |
14 | Correct | 25 ms | 21340 KB | Output is correct |
15 | Correct | 27 ms | 23796 KB | Output is correct |
16 | Correct | 21 ms | 10844 KB | Output is correct |
17 | Correct | 111 ms | 44688 KB | Output is correct |
18 | Correct | 89 ms | 44344 KB | Output is correct |
19 | Correct | 75 ms | 41532 KB | Output is correct |
20 | Correct | 64 ms | 38996 KB | Output is correct |
21 | Correct | 164 ms | 71628 KB | Output is correct |
22 | Correct | 186 ms | 68944 KB | Output is correct |
23 | Correct | 195 ms | 57684 KB | Output is correct |
24 | Correct | 168 ms | 71572 KB | Output is correct |
25 | Correct | 421 ms | 92828 KB | Output is correct |
26 | Correct | 298 ms | 132520 KB | Output is correct |
27 | Correct | 386 ms | 119260 KB | Output is correct |
28 | Correct | 538 ms | 106376 KB | Output is correct |
29 | Correct | 503 ms | 104736 KB | Output is correct |
30 | Correct | 464 ms | 110136 KB | Output is correct |
31 | Correct | 448 ms | 75688 KB | Output is correct |
32 | Correct | 357 ms | 108020 KB | Output is correct |