Submission #1295480

#TimeUsernameProblemLanguageResultExecution timeMemory
1295480ChocoTracks in the Snow (BOI13_tracks)C++20
0 / 100
198 ms271076 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3") #define ll long long #define fori(i,j,k) for(ll i=j; i<=k;i++) #define study ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define pb push_back #define all(s) s.begin(),s.end() #define ins insert #define ss second #define ff first ll sz=4e3+10; ll INF=1e12; ll mod=1e9+7; vector<vector<ll>>v(sz+10,vector<ll>(sz+10,0)),check(sz,vector<ll>(sz,0)); ll dx[]={-1,0,1,0}; ll dy[]={0,1,0,-1}; ll h,w; void dfs(ll i,ll j,ll cl){ check[i][j]=1; fori(k,0,3){ ll x=dx[k]+i; ll y=dy[k]+j; if(x>0 and x<=h and y>0 and y<=w and v[x][y]==cl and check[x][y]==0){ dfs(x,y,cl); } } } void work(){ cin>>h>>w; ll fox=0,rabbit=0; fori(i,1,h){ string s; cin>>s; for(auto x: s){ if(x=='F'){ v[i][x+1]=1; fox=1; } if(x=='R'){ v[i][x+1]=2; rabbit=1; } } } ll oka=0; dfs(1,1,v[1][1]); fori(i,1,h){ fori(j,1,w){ if(v[i][j]==v[1][1] and check[i][j]!=1){ oka=1; break; } } if(oka) break; } cout<<oka+fox+rabbit<<endl; } int main() { study; ll t=1; //cin>>t; fori(i,1,t) work(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...