Submission #152834

#TimeUsernameProblemLanguageResultExecution timeMemory
152834BlagojceTracks in the Snow (BOI13_tracks)C++11
38.75 / 100
2093 ms501588 KiB
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define pb push_back #define st first #define nd second #define pq priority_queue #define all(x) begin(x),end(x) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; ll const inf = 1e9; ll const mod = 1e9 + 7; ld const eps = 1e-9; int const red = 0; int const green = 1; int const neu = 2; int const black = 3; int n, m; int a[4003][4003]; int vis[4003][4003]; int dr[4] = {1, -1, 0, 0}; int dc[4] = {0, 0, 1,-1}; int col; int TIMER = 1; bool ok(int r, int c, int i){ if(r + dr[i] < n && r + dr[i] >= 0 && c + dc[i] < m && c + dc[i] >= 0 && vis[r + dr[i]][c + dc[i]] != TIMER && (a[r + dr[i]][c + dc[i]] == col || a[r + dr[i]][c + dc[i]] == neu)){ return true; } else return false; } int cnt = 0; void floodfill(int r, int c){ cnt ++; fr(i, 0, 4){ if(ok(r, c, i)){ vis[r + dr[i]][c + dc[i]] = TIMER; a[r + dr[i]][c + dc[i]] = neu; floodfill(r + dr[i],c + dc[i]); } } } int main() { memset(vis, 0, sizeof(vis)); ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; int all = n * m; fr(i, 0, n){ fr(j, 0, m){ char c; cin >> c; if(c == 'R') a[i][j] = red; else if(c == 'F') a[i][j] = green; else{ a[i][j] = black; all --; } } } col = a[0][0]; int ziv = 0; cnt = 0; int GET; while(cnt != all){ a[0][0] = col; vis[0][0] = TIMER; cnt = 0; floodfill(0, 0); col ^= 1; ziv ++; TIMER++; } cout << ziv << endl; return 0; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:69:13: warning: unused variable 'GET' [-Wunused-variable]
         int GET;
             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...