제출 #166141

#제출 시각아이디문제언어결과실행 시간메모리
166141gabrc52Miners (IOI07_miners)C++14
100 / 100
693 ms110200 KiB
#include <iostream> #include <unordered_map> #include <cstring> using namespace std; const int MAXN = 100000; char shipment[MAXN + 2]; int N; int memo[MAXN][4][4][4][4]; struct Prev { char a[2][2]; }; Prev give(int pos, int mine, Prev prev) { prev.a[mine][0] = prev.a[mine][1]; prev.a[mine][1] = shipment[pos]; return prev; } int diff(int pos, int mine, Prev prev) { int foodCount[150] = {0}; foodCount[prev.a[mine][0]]++; foodCount[prev.a[mine][1]]++; foodCount[shipment[pos]]++; int typesOfFood = 0; if (foodCount['M']) typesOfFood++; if (foodCount['F']) typesOfFood++; if (foodCount['B']) typesOfFood++; return typesOfFood; } int conversion[150]; int F(int pos, Prev prev) { if (pos == N) { return 0; } else { int &m = memo[pos][ conversion[prev.a[0][0]] ][ conversion[prev.a[0][1]] ][ conversion[prev.a[1][0]] ][ conversion[prev.a[1][1]] ]; if (m == -1) m = max( F(pos + 1, give(pos, 0, prev)) + diff(pos, 0, prev), F(pos + 1, give(pos, 1, prev)) + diff(pos, 1, prev) ); return m; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); memset(memo, -1, sizeof memo); conversion[0] = 0; conversion['M'] = 1; conversion['F'] = 2; conversion['B'] = 3; cin >> N >> shipment; cout << F(0, {{{0, 0}, {0, 0}}}) << '\n'; }

컴파일 시 표준 에러 (stderr) 메시지

miners.cpp: In function 'int diff(int, int, Prev)':
miners.cpp:25:27: warning: array subscript has type 'char' [-Wchar-subscripts]
  foodCount[prev.a[mine][0]]++;
                           ^
miners.cpp:26:27: warning: array subscript has type 'char' [-Wchar-subscripts]
  foodCount[prev.a[mine][1]]++;
                           ^
miners.cpp:27:25: warning: array subscript has type 'char' [-Wchar-subscripts]
  foodCount[shipment[pos]]++;
                         ^
miners.cpp: In function 'int F(int, Prev)':
miners.cpp:44:46: warning: array subscript has type 'char' [-Wchar-subscripts]
   int &m = memo[pos][ conversion[prev.a[0][0]] ][ conversion[prev.a[0][1]] ][ conversion[prev.a[1][0]] ][ conversion[prev.a[1][1]] ];
                                              ^
miners.cpp:44:74: warning: array subscript has type 'char' [-Wchar-subscripts]
   int &m = memo[pos][ conversion[prev.a[0][0]] ][ conversion[prev.a[0][1]] ][ conversion[prev.a[1][0]] ][ conversion[prev.a[1][1]] ];
                                                                          ^
miners.cpp:44:102: warning: array subscript has type 'char' [-Wchar-subscripts]
   int &m = memo[pos][ conversion[prev.a[0][0]] ][ conversion[prev.a[0][1]] ][ conversion[prev.a[1][0]] ][ conversion[prev.a[1][1]] ];
                                                                                                      ^
miners.cpp:44:130: warning: array subscript has type 'char' [-Wchar-subscripts]
   int &m = memo[pos][ conversion[prev.a[0][0]] ][ conversion[prev.a[0][1]] ][ conversion[prev.a[1][0]] ][ conversion[prev.a[1][1]] ];
                                                                                                                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...