#include <iostream>
#include <iomanip>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
#define inf 1e9
#define sz(v) (ll)v.size()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define dbg(x) cerr<<#x<<": "<<x<<"\n";
#define fr(i, x) for(ll i=0 ; i<x ; i++)
#define fra(x, v) for(auto x:v)
#define fra1(x,v) for(auto &x:v)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define pb(x) push_back(x)
#define pll pair<ll, ll>
#define vll vector<ll>
#define mk(a, b) make_pair(a, b)
#define F first
#define S second
/*
const long long maxN=0;
que es eso??
un maxN con 0
que pront
bueno muchachos a dormir
*/
const double PI=acos(-1);
const ll MOD=1e9+7;
ll binpow(ll a, ll b){
ll cc=1;
while(b){
if(b&1) cc*=a;
a*=a;
b>>=1;
}
return cc;
}
ll binpow1(ll a, ll b, ll uwu){
ll cc=1;
while(b){
if(b&1) cc=cc*a%uwu;
a=a*a%uwu;
b>>=1;
}
return cc%uwu;
}
ll log2uwu(ll n){
fr(i, n+1){
if((1<<i) > n) return i-1;
}
return -1;
}
bool comp(string a, string b){
if(a.size()==b.size()){
fr(i, a.size()){
if(a[i]>b[i]) return 1;
else if(a[i]<b[i]) return 0;
}
return 0;
}else{
return a.size()>b.size();
}
}
ll isCousin(ll x){
for(ll i=2 ; i*i <= x ; i++){
if(!(x%i)) return i;
}
return 0;
}
ll webos(ll x){
fr(i, x){
if(i*i>x) return i-1;
}
return -1;
}
bool ok(ll mid, vll v, ll n, ll k){
ll cc=1, sum=0;
fra(x, v){
if(x>mid) return false;
sum+=x;
if(sum>mid){
sum=x;
cc++;
}
}
if(cc<=k) return true;
else return false;
}
ll xdxd(ll x){
fr(i, x+1){
if(i==0) continue;
//dbg(i*i*i);
if(i*i*i == x) return i;
else if(i*i*i > x) return -1;
}
return -1;
}
ll tilin(ll v, ll k, ll n){
ll cc=v;
for(ll i=1 ; i<n ; i++){
ll pro=v/pow(k, i);
if(pro>0)cc+=pro;
if(cc>=n || pro<=0){
return cc;
}
}
return cc;
}
struct point{
ll x, y, z;
};
const ll maxN=101;
char lab[maxN][maxN];
ll n, m, aux=0;
ll move(ll i, ll j){
if(lab[i][j]=='x') return aux;
if(lab[i][j]=='.'){
return aux=-1;
}
if(i==-1 || j==-1 || i==n || j==m) return aux=-1;
aux++;
if(lab[i][j]=='<') return move(i, j-1);
if(lab[i][j]=='>') return move(i, j+1);
if(lab[i][j]=='^') return move(i-1, j);
if(lab[i][j]=='v') return move(i+1, j);
return 0;
}
void solve(){
cin>>n>>m;
ll x=0, y=0;
fr(i, n){
fr(j, m){
cin>>lab[i][j];
if(lab[i][j]=='o'){
x=i; y=j;
}
}
}
char ans='X';
ll cc=inf;
aux=0;
move(x-1, y);
if(aux<cc && aux>=0){
cc=aux; ans='N';
}
aux=0;
move(x+1, y);
//dbg(aux);
if(aux<cc && aux>=0){
cc=aux; ans='S';
}
aux=0;
move(x, y-1);
if(aux<cc && aux>=0){
cc=aux; ans='O';
}
aux=0;
move(x, y+1);
if(aux<cc && aux>=0){
cc=aux; ans='E';
}
if(ans=='X') cout<<":(\n";
else{
cout<<":)\n"<<ans<<"\n";
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
Compilation message
patkice.cpp: In function 'bool comp(std::string, std::string)':
patkice.cpp:22:32: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | #define fr(i, x) for(ll i=0 ; i<x ; i++)
......
75 | fr(i, a.size()){
| ~~~~~~~~~~~
patkice.cpp:75:9: note: in expansion of macro 'fr'
75 | fr(i, a.size()){
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |