Submission #534342

#TimeUsernameProblemLanguageResultExecution timeMemory
534342aadit_ambadkarTracks in the Snow (BOI13_tracks)C++17
0 / 100
1030 ms1027612 KiB
/* This code belongs to Aadit Ambadkar Date: 2022-03-07 21:34:47 Problem: tis */ #include <bits/stdc++.h> using namespace::std; typedef long long ll; #define F0R(i, n) for (int i = 0; i < n; i++) #define R0F(i, n) for (int i = n-1; i >= 0; i--) #define FOR(i, a, n) for (int i = a; i < n; i++) #define pb push_back #define fastio ios::sync_with_stdio(0); cin.tie(0) #define MOD 1000000007 #define FF first #define SS second int n, m; int board[4005][4005]; bool vis[4005][4005]; int cc = 0; void dfs(int u, int v, int g) { if (vis[u][v]) return; vis[u][v]=true; if (board[u][v]==g) cc++; else return; if (u > 0) dfs(u-1, v, g); if (v > 0) dfs(u, v-1, g); if (u < n-1) dfs(u+1, v, g); if (v < m-1) dfs(u, v+1, g); } int main() { fastio; cin >> n >> m; string s; int cg = 0; F0R(i, n) { cin >> s; F0R(j, m) { if (s[i]=='F') board[i][j]=1; else if (s[i]=='R') board[i][j]=2; else board[i][j]=0; if (board[i][j]==board[0][0]) cg++; } } int v = board[0][0]; dfs(0, 0, v); if (cc < cg) { cout << 3 << "\n"; } else { cout << 2 << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...