# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
875936 | 2023-11-20T19:16:47 Z | 431jericho | Tracks in the Snow (BOI13_tracks) | C++14 | 2000 ms | 2736 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define INF (int)1e18 #define endl '\n' const int mod = 1000 * 1000 * 1000 + 7; const int N = 4005; #define f first #define s second mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count()); char a[N][N]; queue<pair<int,int> > pq , nq; int vis[N][N]; int dx[4] = {1,0,-1,0}; int dy[4] = {0,1,0,-1}; void Solve() { int n , m; cin>>n>>m; for(int i = 1 ;i<= n ; i++){ for(int j = 1; j<= m ; j++){ cin>>a[i][j]; } } int cnt = 0; char c ; vis[1][1] = true; pq.push({1,1}); while (!pq.empty()){ cnt++; c = a[pq.front().first][pq.front().second]; while (!pq.empty())nq.push(pq.front()) , pq.pop(); while (!nq.empty()){ auto v = nq.front(); nq.pop(); for (int i = 0; i < 4; ++i) { int nx = v.first+dx[i], ny = v.second + dy[i]; if (nx<1 || ny<1 ||nx>n ||ny>m || a[nx][ny]=='.' || vis[nx][ny]){ vis[nx][ny] = true; if (a[nx][ny]==c){ nq.push({nx,ny}); } else{ pq.push({nx,ny}); } } } } } cout<<cnt<<endl; } int32_t main() { auto begin = std::chrono::high_resolution_clock::now(); ios_base::sync_with_stdio(false); cin.tie(0); #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif int t = 1; // cin >> t; for (int i = 1; i <= t; i++) { //cout << "Case #" << i << ": "; Solve(); } auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin); cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2017 ms | 2392 KB | Time limit exceeded |
2 | Execution timed out | 2054 ms | 2396 KB | Time limit exceeded |
3 | Execution timed out | 2084 ms | 2392 KB | Time limit exceeded |
4 | Execution timed out | 2012 ms | 2392 KB | Time limit exceeded |
5 | Execution timed out | 2025 ms | 2392 KB | Time limit exceeded |
6 | Execution timed out | 2013 ms | 2392 KB | Time limit exceeded |
7 | Execution timed out | 2029 ms | 2648 KB | Time limit exceeded |
8 | Execution timed out | 2066 ms | 2396 KB | Time limit exceeded |
9 | Execution timed out | 2041 ms | 2392 KB | Time limit exceeded |
10 | Execution timed out | 2035 ms | 2392 KB | Time limit exceeded |
11 | Execution timed out | 2020 ms | 2392 KB | Time limit exceeded |
12 | Execution timed out | 2045 ms | 2392 KB | Time limit exceeded |
13 | Execution timed out | 2055 ms | 2396 KB | Time limit exceeded |
14 | Execution timed out | 2050 ms | 2396 KB | Time limit exceeded |
15 | Execution timed out | 2054 ms | 2396 KB | Time limit exceeded |
16 | Execution timed out | 2041 ms | 2392 KB | Time limit exceeded |
17 | Execution timed out | 2041 ms | 2552 KB | Time limit exceeded |
18 | Execution timed out | 2029 ms | 2392 KB | Time limit exceeded |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2063 ms | 2396 KB | Time limit exceeded |
2 | Execution timed out | 2023 ms | 2656 KB | Time limit exceeded |
3 | Execution timed out | 2045 ms | 2736 KB | Time limit exceeded |
4 | Execution timed out | 2035 ms | 2396 KB | Time limit exceeded |
5 | Execution timed out | 2033 ms | 2392 KB | Time limit exceeded |
6 | Execution timed out | 2016 ms | 2396 KB | Time limit exceeded |
7 | Execution timed out | 2053 ms | 2396 KB | Time limit exceeded |
8 | Execution timed out | 2059 ms | 2396 KB | Time limit exceeded |
9 | Execution timed out | 2019 ms | 2392 KB | Time limit exceeded |
10 | Execution timed out | 2041 ms | 2396 KB | Time limit exceeded |
11 | Execution timed out | 2037 ms | 2396 KB | Time limit exceeded |
12 | Execution timed out | 2005 ms | 2396 KB | Time limit exceeded |
13 | Execution timed out | 2060 ms | 2396 KB | Time limit exceeded |
14 | Execution timed out | 2087 ms | 2392 KB | Time limit exceeded |
15 | Execution timed out | 2027 ms | 2392 KB | Time limit exceeded |
16 | Execution timed out | 2035 ms | 2392 KB | Time limit exceeded |
17 | Execution timed out | 2016 ms | 2392 KB | Time limit exceeded |
18 | Execution timed out | 2059 ms | 2396 KB | Time limit exceeded |
19 | Execution timed out | 2044 ms | 2392 KB | Time limit exceeded |
20 | Execution timed out | 2053 ms | 2396 KB | Time limit exceeded |
21 | Execution timed out | 2067 ms | 2396 KB | Time limit exceeded |
22 | Execution timed out | 2052 ms | 2396 KB | Time limit exceeded |
23 | Execution timed out | 2057 ms | 2396 KB | Time limit exceeded |
24 | Execution timed out | 2009 ms | 2392 KB | Time limit exceeded |
25 | Execution timed out | 2070 ms | 2648 KB | Time limit exceeded |
26 | Execution timed out | 2062 ms | 2396 KB | Time limit exceeded |
27 | Execution timed out | 2015 ms | 2392 KB | Time limit exceeded |
28 | Execution timed out | 2027 ms | 2392 KB | Time limit exceeded |
29 | Execution timed out | 2040 ms | 2648 KB | Time limit exceeded |
30 | Execution timed out | 2011 ms | 2392 KB | Time limit exceeded |
31 | Execution timed out | 2031 ms | 2392 KB | Time limit exceeded |
32 | Execution timed out | 2069 ms | 2396 KB | Time limit exceeded |