Submission #1120895

#TimeUsernameProblemLanguageResultExecution timeMemory
1120895Haciyev12Tracks in the Snow (BOI13_tracks)C++17
100 / 100
1799 ms311500 KiB
#include "bits/stdc++.h" #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long #define pb push_back #define in insert #define F first #define S second #define vll vector<ll> #define all(v) v.begin(),v.end() #define endl '\n' #define pii pair<ll,ll> using namespace std; const ll INF =1e18, mod = 1e9 + 7, N = 3e5 + 5; ll n,m; ll a[4005][4005]; ll st; ll ans = 0; queue<pii>q; ll dx[4] = {-1,1, 0, 0}; ll dy[4] = {0, 0, -1, 1}; ll used[4005][4005]; vector<pii>q1; bool test; void ch(){ test = false; while(!q.empty()){ ll x = q.front().F; ll y = q.front().S; q.pop(); if(used[x][y] == 1){ continue; } used[x][y] = 1; for(int i = 0; i < 4; i++){ ll nx = x + dx[i]; ll ny = y + dy[i]; if(nx < 0 || nx >= n || ny < 0 || ny >= m){ continue; } if(used[nx][ny] == 0 && st == a[nx][ny]){ q.push({nx,ny}); } else if(used[nx][ny] == 0 && -st == a[nx][ny]){ q1.pb({nx,ny});//check again test = true; } } } if(test){ ans++; for(int i = 0; i < q1.size(); i++){ q.push({q1[i].F,q1[i].S}); } q1.clear(); st = -st;//swap ch(); } } /* x y 0 z a */ void solve(){ cin >> n >> m; char c; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cin >> c; if(c == 'R'){ a[i][j] = 1; } else if(c == 'F'){ a[i][j] = -1; } } } st = a[0][0]; q.push({0,0}); ch(); cout << ans + 1<< endl; } int main(){ fast; solve(); return 0; }

Compilation message (stderr)

tracks.cpp: In function 'void ch()':
tracks.cpp:55:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             for(int i = 0; i < q1.size(); i++){
      |                            ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...