#include <vector>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_map>
#include <map>
#include <queue>
#include <cmath>
#include <cstdint>
#include <climits>
#include <string>
#include <cstdlib>
#include <stack>
using namespace std;
void setIO(std::string name = "", int precision = -1) {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
if (!name.empty()) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
if (precision >= 0) {
std::cout << std::fixed << std::setprecision(precision);
}
}
template <typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
using ll = long long;
using ull = unsigned long long;
// Sparse Table (idempotent op) — O(1) query, O(n log n) build
// Requirements on Op: associative + idempotent: f(x,x) = x
// Query is inclusive on [l, r].
#include <vector>
#include <cassert>
#include <algorithm>
template <typename T, class Op>
struct SparseTable {
int n = 0; // number of elements
int K = 0; // number of layers
std::vector<int> lg; // floor(log2(i)) for i
std::vector<std::vector<T>> st; // st[k][i] covers [i, i + 2^k - 1]
Op op; // idempotent combine
SparseTable() = default;
explicit SparseTable(const std::vector<T>& a, const Op& op = Op()) : op(op) {
build(a);
}
template <class It>
SparseTable(It first, It last, const Op& op = Op()) : op(op) {
std::vector<T> a(first, last);
build(a);
}
void build(const std::vector<T>& a) {
n = (int)a.size();
assert(n > 0 && "SparseTable: empty input");
lg.assign(n + 1, 0);
for (int i = 2; i <= n; ++i) lg[i] = lg[i >> 1] + 1;
K = lg[n] + 1;
st.assign(K, std::vector<T>(n));
st[0] = a;
for (int k = 1; k < K; ++k) {
int len = 1 << k, half = len >> 1;
for (int i = 0; i + len <= n; ++i) {
st[k][i] = op(st[k - 1][i], st[k - 1][i + half]);
}
}
}
// Query on inclusive range [l, r]; 0 <= l <= r < n
T query(int l, int r) const {
assert(0 <= l && l <= r && r < n);
int k = lg[r - l + 1];
// Two overlapping blocks of length 2^k (needs idempotent op)
return op(st[k][l], st[k][r - (1 << k) + 1]);
}
};
template <typename T>
struct Min {
T operator()(const T& a, const T& b) const { return a < b ? a : b; }
};
// Max
template <typename T>
struct Max {
T operator()(const T& a, const T& b) const { return a > b ? a : b; }
};
template <typename T>
struct GCD {
T operator()(T a, T b) const { return std::gcd(a, b); }
};
template <typename T>
struct BitAnd {
T operator()(const T& a, const T& b) const { return a & b; }
};
template <typename T>
struct BitOr {
T operator()(const T& a, const T& b) const { return a | b; }
};
int n;
vector<vector<int>> adj;
vector<int> mxd, depth;
void dfs(int v, int p, int d) {
depth[v] = mxd[v] = d;
for (int u : adj[v]) {
if (u == p) { continue; }
dfs(u, v, d + 1);
mxd[v] = max(mxd[v], mxd[u]);
}
}
int mn = 1e9;
void solve() {
int n, m; cin >> n >> m;
bool f = false, r = false;
for (int i = 0; i < n; ++i) {
string s; cin >> s;
if (s.find('R') != string::npos) { r = true; }
if (s.find('F') != string::npos) { f = true; }
}
cout << (f && r ? 2 : 1) << '\n';
}
int main() {
setIO("");
int t = 1;
// cin >> t;
for (int i = 1; i <= t; ++i) {
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
tracks.cpp: In function 'void setIO(std::string, int)':
tracks.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | freopen((name + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
27 | freopen((name + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |