Submission #491265

#TimeUsernameProblemLanguageResultExecution timeMemory
491265ktkeremZoo (COCI19_zoo)C++17
110 / 110
51 ms10256 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; ll _i=0; #define ffn(x) _i=x #define llll pair<ll , ll> #define stitr set<llll>::iterator #define fora(y,x) for(ll y=_i;x>y;y++) #define pb push_back #define pf push_front #define debu cout << "hello\n" #define fi first #define sec second const ll limit = 1e9+7; const ll ous=1e5 + 5; const ll dx[4] = {1 , -1 , 0 , 0} , dy[4] = {0,0,-1,1}; ll vis[1005][1005]; void solve(){ ll n ,m ;cin >> n >> m; string h[n]; fora(i,n){ cin >> h[i]; } ll ans = 0; stack<llll> st; st.push({(n-1) , (m-1)}); while(!st.empty()){ vector<llll> ko; ans++; char o = h[st.top().fi][st.top().sec]; while(!st.empty()){ llll a= st.top(); st.pop(); vis[a.fi][a.sec] = 1; fora(i , 4){ if(n>a.fi + dx[i] && 0<= a.fi + dx[i] && m> a.sec + dy[i] && 0 <= a.sec + dy[i] && vis[a.fi + dx[i]][a.sec + dy[i]] == 0 && h[a.fi + dx[i]][a.sec + dy[i]] != '*'){ if(h[a.fi + dx[i]][a.sec + dy[i]] != o){ ko.pb({a.fi + dx[i] , a.sec + dy[i]}); vis[a.fi + dx[i]][a.sec + dy[i]] = 2; } else{ vis[a.fi + dx[i]][a.sec + dy[i]] = 1; st.push({a.fi + dx[i] , a.sec + dy[i]}); } } } } fora(i , ko.size()){ st.push({ko[i].fi , ko[i].sec}); } } cout << ans << "\n"; return; } int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); ll t=1; //cin >> t; while(t--){ solve(); } return 0; }

Compilation message (stderr)

zoo.cpp: In function 'void solve()':
zoo.cpp:9:32: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
    9 | #define fora(y,x) for(ll y=_i;x>y;y++)
......
   49 |         fora(i , ko.size()){
      |                                 
zoo.cpp:49:9: note: in expansion of macro 'fora'
   49 |         fora(i , ko.size()){
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...