이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a)
#define EACH(a, x) for (auto& a : x)
ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); }
ll fdiv(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); }
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T> void remDup(vector<T>& v) { sor(v); v.erase(unique(all(v)), v.end()); }
const int MOD = 1e9 + 7;
const int MX = 1e5 + 10;
const ll INF = 1e18;
int N; int DP[MX][4][4][4][4]; unordered_set<int> cnt;
int numPoints(int A, int B, int C) {
cnt.clear(); if (A) cnt.insert(A); if (B) cnt.insert(B); if (C) cnt.insert(C); return sz(cnt);
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> N; memset(DP, -1, sizeof DP); DP[0][0][0][0][0] = 0; // 'M' = 1, 'F' = 2, 'B' = 3
F0R(i, N) {
char CH; cin >> CH;
F0R(A, 4) {
F0R(B, 4) {
F0R(C, 4) {
F0R(D, 4) {
if (DP[i][A][B][C][D] != -1) {
int ID;
if (CH == 'M') ID = 1;
if (CH == 'F') ID = 2;
if (CH == 'B') ID = 3;
ckmax(DP[i + 1][ID][A][C][D], DP[i][A][B][C][D] + numPoints(ID, A, B));
ckmax(DP[i + 1][A][B][ID][C], DP[i][A][B][C][D] + numPoints(ID, C, D));
}
}
}
}
}
}
int ans = 0;
F0R(A, 4) {
F0R(B, 4) {
F0R(C, 4) {
F0R(D, 4) {
ckmax(ans, DP[N][A][B][C][D]);
}
}
}
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
miners.cpp: In function 'int main()':
miners.cpp:51:59: warning: 'ID' may be used uninitialized in this function [-Wmaybe-uninitialized]
51 | template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
| ~~^~~
miners.cpp:78:33: note: 'ID' was declared here
78 | int ID;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |