Submission #651559

#TimeUsernameProblemLanguageResultExecution timeMemory
651559edogawa_somethingPatkice (COCI20_patkice)C++17
30 / 50
1 ms340 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; typedef long long ll; typedef long double ld; typedef string st; typedef bool bl; typedef vector<ll> vii; typedef pair<ll,ll> pii; typedef vector<pii> vpi; #define pu push #define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> #define fast ios_base::sync_with_stdio(0);cin.tie(); #define test ll qqqqq;cin>>qqqqq;while(qqqqq--) #define F first #define S second #define forn(i,n) for(ll i=0;i<n;i++) #define forx(i,j,n) for(ll i=j;i<n;i++) #define pb push_back #define pob pop_back #define all(v) v.begin(),v.end() #define lb lower_bound #define ub upper_bound #define pof pop_front #define pow powww const ll dx[]{1,0,-1,0}; const ll dy[]{0,-1,0,1}; const ll inf=2e18; const ll mod=1e9+7; const ll M=1e6+1; const ll MM=202; const ll MMM=101; const ld pi=acos(-1); const ll mod1=1000000321; char c[MM][MM]; ll n,dir,m,len=inf,curlen; pii ind; bl vis[MM][MM]; bl can(ll d){ pii cur=ind; curlen=0; forn(i,n) forn(j,m) vis[i][j]=0; while(c[cur.F][cur.S]!='.'){ char cc=c[cur.F][cur.S]; if(vis[cur.F][cur.S]) return 0; vis[cur.F][cur.S]=1; if(cc=='o') cur.F+=dx[d],cur.S+=dy[d]; else if(cc=='^') cur.F--; else if(cc=='>') cur.S++; else if(cc=='v') cur.F++; else if(cc=='<') cur.S--; else if(cc=='.') return 0; else{ curlen++; return 1; } curlen++; } return 0; } int main(){ fast cin>>n>>m; forn(i,n) forn(j,m){ cin>>c[i][j]; if(c[i][j]=='o') ind={i,j}; } bl chk=0; forn(i,4){ if(can(i)&&curlen<=len) chk=1,dir=i,len=curlen; } if(!chk) cout<<":("; else{ cout<<":)\n"; if(dir==0) cout<<'S'; else if(dir==1) cout<<'W'; else if(dir==2) cout<<'N'; else cout<<'E'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...