This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
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";
}
}
Compilation message (stderr)
tracks.cpp: In function 'int main()':
tracks.cpp:44:29: warning: statement has no effect [-Wunused-value]
44 | else board[i][j]==0;
| ~~~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |