Submission #321462

#TimeUsernameProblemLanguageResultExecution timeMemory
321462ronnithZoo (COCI19_zoo)C++14
0 / 110
1 ms364 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #warning Check Integer OverFlow #define ll long long #define FOR(i,a,b) for(int i=a;i<b;i++) #define FORd(i,a,b) for(int i=a;i>=b;i--) #define trav(a,b) for(auto a:b) #define sz(a) a.size() #define maxs(a,b) if(b>a)a=b #define mins(a,b) if(b<a)a=b #ifdef LOCAL #define dbg(x) cerr<<"["<<#x<<":"<<x<<"] " #define dbg2(a,b) dbg(a);dbg(b) #define dbg3(a,b,c) dbg2(a,b);dbg(c) #define dln cerr << ln #else #define dbg(x) 0 #define dbg2(a,b) 0 #define dbg3(a,b,c) 0 #define dln 0 #endif #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (((a)/(__gcd(a,b))) * b) #define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln; #define all(a) (a).begin(), (a).end() #define vi vector<int> #define v vector #define p pair #define pii p<int,int> #define pb push_back #define mk make_pair #define f first #define s second #define ln "\n" typedef long double ld; using namespace std; using namespace __gnu_pbds; ll modF=1e9+7; template<class T> using iset = tree< T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; /*INPUT 1 0 1000 1 1000 3 2 1 2 3 1 2 1 3 3 2 3 5 14 13 2 3 4 19 20 21 5 22 6 7 23 8 10 14 1 2 1 3 1 4 2 5 2 6 3 7 3 8 3 9 4 10 8 11 10 13 10 12 12 14 3 45 44 23 */ #define maxn 1000 int N, M, vis[maxn][maxn]; char m, a[maxn][maxn]; int dx[4] = {1,-1,0,0}; int dy[4] = {0,0,1,-1}; void ff(int i,int j) { if(i >= N or i < 0 or j >= M or j < 0)return; if(vis[i][j])return; if(a[i][j] != m)return; vis[i][j] = 1; FOR(k,0,4)ff(i + dx[k],j + dy[k]); } void solve(){ cin >> N >> M; FOR(i,0,N) { FOR(j,0,M) { cin >> a[i][j]; } } m = a[0][0]; int cnt = 0; bool pos = false; FOR(i,0,N) { FOR(j,0,M) { if(a[i][j] != '*' and a[i][j] != m)pos = true; if(vis[i][j] == 0 and a[i][j] == m) { cnt ++; ff(i,j); } } } // if(cnt > 1) // { // cout << 3 << '\n'; // } // else if(cnt == 1 and pos) // { // cout << 2 << '\n'; // } // else // { // cout << 1 << '\n'; // } cout << 1 << '\n'; } int main(){ ios::sync_with_stdio(0);cin.tie(0); int t = 1; // cin >> t; while(t --){ solve(); } }

Compilation message (stderr)

zoo.cpp:4:2: warning: #warning Check Integer OverFlow [-Wcpp]
    4 | #warning Check Integer OverFlow
      |  ^~~~~~~
zoo.cpp: In function 'void solve()':
zoo.cpp:113:7: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
  113 |  bool pos = false;
      |       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...