제출 #660843

#제출 시각아이디문제언어결과실행 시간메모리
660843KenparPatkice (COCI20_patkice)C++17
50 / 50
1 ms340 KiB
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define endl '\n'

const ll MOD = 1e9+7;
const ll INF = 1e16;
const ll MAX = 2 * 1e5;
int n,m;
char arr[101][101];

int DFS(int x, int y){
	if(arr[x][y] == 'o' || arr[x][y] == '.') return -1e8;

	if(arr[x][y] == 'x') return 0;

	if(arr[x][y] == '>') return DFS(x, y+1) + 1;
	if(arr[x][y] == '<') return DFS(x, y-1) + 1;
	if(arr[x][y] == 'v') return DFS(x + 1, y) + 1;

	return DFS(x - 1, y) + 1;
}

void solve(){
	cin>>n>>m;

	pair<int,int> start;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin>>arr[i][j];

			if(arr[i][j] == 'o') start = {i,j};
		}
	}

	vector<pair<int, char>> ans;

	int temp = DFS(start.first, start.second + 1);

	if(temp >= 0)
		ans.push_back({temp, 'E'});

	temp = DFS(start.first, start.second - 1);

	if(temp >= 0)
		ans.push_back({temp, 'W'});

	temp = DFS(start.first - 1, start.second);

	if(temp >= 0)
		ans.push_back({temp, 'N'});

	temp = DFS(start.first + 1, start.second);

	if(temp >= 0)
		ans.push_back({temp, 'S'});

	if(ans.size() == 0){
		cout<<":(";
	}else{
		sort(ans.begin(), ans.end());
		cout<<":)"<<endl;
		cout<<ans[0].second;
	}
}


int main()
{
    cin.tie(NULL);
    ios::sync_with_stdio(NULL);
    int t = 1;

    //cin>>t;
    int temp = t;
    while(t--){
        //cout<<"Case #"<<temp - t<<" > "<<endl;
        solve();

        cout<<endl;
    }

    cout.flush();
}

컴파일 시 표준 에러 (stderr) 메시지

patkice.cpp: In function 'int main()':
patkice.cpp:76:9: warning: unused variable 'temp' [-Wunused-variable]
   76 |     int temp = t;
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...