Submission #938005

#TimeUsernameProblemLanguageResultExecution timeMemory
938005kitlixDango Maker (JOI18_dango_maker)C++17
100 / 100
955 ms262144 KiB
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; vector<vector<int>> g; vector<int> used, mt; int timer = 1; bool kuhn(int v) { if (used[v] == timer) return false; used[v] = timer; for (auto to : g[v]) { if (mt[to] == -1) { mt[to] = v; return true; } } for (auto to : g[v]) { if (kuhn(mt[to])) { mt[to] = v; return true; } } return false; } signed main() { ios_base::sync_with_stdio(0), cin.tie(0); int n, m; cin >> n >> m; vector<vector<int>> table(n, vector<int>(m)); for (auto& r : table) { string s; cin >> s; for (int j = 0; j < m; ++j) { if (s[j] == 'R') r[j] = 0; else if (s[j] == 'G') r[j] = 1; else r[j] = 2; } } int allcnt = 0; vector<vector<int>> has_vert(n, vector<int>(m, -1)); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (table[i][j]) continue; if (i + 2 < n) { if (table[i + 1][j] == 1 && table[i + 2][j] == 2) { has_vert[i][j] = allcnt; mt.emplace_back(-1); allcnt += 1; } } } } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (table[i][j]) continue; if (j + 2 < m) { if (table[i][j + 1] == 1 && table[i][j + 2] == 2) { allcnt += 1; g.emplace_back(); used.emplace_back(); if (has_vert[i][j] != -1) g[g.size() - 1].push_back(has_vert[i][j]); if (i - 1 >= 0 && j + 1 < m && has_vert[i - 1][j + 1] != -1) g[g.size() - 1].push_back(has_vert[i - 1][j + 1]); if (i - 2 >= 0 && j + 2 < m && has_vert[i - 2][j + 2] != -1) g[g.size() - 1].push_back(has_vert[i - 2][j + 2]); } } } } for (int i = 0; i < g.size(); ++i) if (kuhn(i)) timer += 1; int bipmt = 0; for (int i = 0; i < mt.size(); ++i) if (mt[i] != -1) bipmt += 1; cout << allcnt - bipmt; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:81:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |     for (int i = 0; i < g.size(); ++i)
      |                     ~~^~~~~~~~~~
dango_maker.cpp:85:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |     for (int i = 0; i < mt.size(); ++i)
      |                     ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...