Submission #279994

#TimeUsernameProblemLanguageResultExecution timeMemory
279994Haunted_CppI want to be the very best too! (NOI17_pokemonmaster)C++17
27 / 100
5086 ms10176 KiB
/** * author: Haunted_Cpp **/ #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("unroll-loops") template<typename T> ostream &operator << (ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; } template<typename T, size_t size> ostream &operator << (ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; } template<typename A, typename B> ostream &operator << (ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } void debug_out() { cerr << endl; } template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__) #else #define debug(...) 47 #endif bitset<50005> cnt; const int dr[] = {+1, -1, +0, +0}; const int dc[] = {+0, +0, -1, +1}; int main() { ios::sync_with_stdio(0); cin.tie(0); int r, c, q; cin >> r >> c >> q; vector<vector<int>> lvl(r, vector<int>(c)); vector<vector<int>> type(r, vector<int>(c)); for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cin >> lvl[i][j]; } } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cin >> type[i][j]; } } while(q--) { int task; cin >> task; if (task == 1) { int linha, coluna, new_type; cin >> coluna >> linha >> new_type; --coluna; --linha, type[linha][coluna] = new_type; } else { cnt.reset(); int linha, coluna, max_lvl; cin >> coluna >> linha >> max_lvl; --coluna; --linha; vector<vector<bool>> vis(r, vector<bool>(c, false)); function<void(int, int)> dfs = [&](int linha, int coluna) { vis[linha][coluna] = true; cnt[type[linha][coluna]] = true; for (int i = 0; i < 4; i++) { if (linha + dr[i] < 0 || linha + dr[i] >= r || coluna + dc[i] < 0 || coluna + dc[i] >= c) continue; if (lvl[linha + dr[i]][coluna + dc[i]] > max_lvl) continue; if (vis[linha + dr[i]][coluna + dc[i]]) continue; vis[linha + dr[i]][coluna + dc[i]]; dfs(linha + dr[i], coluna + dc[i]); } }; if (lvl[linha][coluna] <= max_lvl) dfs(linha, coluna); cout << cnt.count() << '\n'; } } return 0; }
#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...