Submission #440431

#TimeUsernameProblemLanguageResultExecution timeMemory
440431Abrar_Al_SamitEmacs (COCI20_emacs)C++17
0 / 50
218 ms179948 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define debug(x) cerr << '[' << (#x) << "] = " << x << '\n'; template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update> ; void PlayGround() { int n, m; cin >> n >> m; vector<string>g(n); for(string& row : g) cin >> row; int ans = 0; auto BFS = [&] (int i, int j) { queue<pair<int,int>>q; q.push({i, j}); auto valid = [=] (int x, int y) { return x>-1 && y>-1 && x<n && y<m && g[x][y]=='*'; }; while(!q.empty()) { pair<int,int>cur = q.front(); q.pop(); if(g[cur.first][cur.second]!='*') continue; g[cur.first][cur.second] = '.'; int dx[] {1, -1, 0, 0}; int dy[] {0, 0, 1, -1}; for(int k=0; k<4; ++k) { int new_i = cur.first + dx[k], new_j = cur.second + dy[k]; if(valid(new_i, new_j)) q.push({new_i, new_j}); } } }; for(int i=0; i<n; ++i) { for(int j=0; j<m; ++j) { if(g[i][j]=='*') { BFS(i, j), ++ans; } } } cout << ans << '\n'; #ifndef ONLINE_JUDGE cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); #endif PlayGround(); return 0; }

Compilation message (stderr)

emacs.cpp: In function 'int main()':
emacs.cpp:59:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...