이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
#define ll long long
set<pii> s;
int dx[512], dy[512];
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, k; cin >> n >> k;
string A; cin >> A;
dx['S']--, dx['N']++, dy['E']++, dy['W']--;
int x = 0, y = 0;
s.insert({x,y});
ll dc = 0,ct = 0, pc = 0;
for(;k;){
k--;
for(char i : A) {
x += dx[i], y += dy[i];
s.insert({x,y});
}
ll c = 0;
for(auto i : s) if(
s.find({i.first+1,i.second}) != s.end() &&
s.find({i.first,i.second+1}) != s.end() &&
s.find({i.first+1,i.second+1}) != s.end()
) c++;
if(c-pc==dc) ct++;
else dc = c-pc, ct = 1;
pc = c;
if(ct>=5) break;
}
cout << pc+dc*k;
}
컴파일 시 표준 에러 (stderr) 메시지
2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:18:21: warning: array subscript has type 'char' [-Wchar-subscripts]
18 | x += dx[i], y += dy[i];
| ^
2016_ho_t4.cpp:18:33: warning: array subscript has type 'char' [-Wchar-subscripts]
18 | x += dx[i], y += dy[i];
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |