# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
137101 | arnold518 | 영역 (JOI16_ho_t4) | C++14 | 68 ms | 5344 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5;
#define x first
#define y second
int N, K;
char S[MAXN+10];
set<pii> ST;
vector<int> V;
ll ans;
int main()
{
int i, j;
scanf("%d%d%s", &N, &K, S+1);
pii now={0, 0}; ST.insert(now);
V.push_back(0);
for(j=1; j<=K; j++)
{
int a=0;
for(i=1; i<=N; i++)
{
if(S[i]=='N') now.y++;
else if(S[i]=='S') now.y--;
else if(S[i]=='W') now.x--;
else now.x++;
ST.insert(now);
}
for(auto it : ST) a+=(ST.count({it.x, it.y}) && ST.count({it.x+1, it.y}) && ST.count({it.x, it.y+1}) && ST.count({it.x+1, it.y+1}));
V.push_back(a);
if(j>20 && V[j]-V[j-1]==V[j-1]-V[j-2])
{
printf("%lld", V[j]+(ll)(K-j)*(V[j]-V[j-1]));
return 0;
}
}
printf("%lld", V[K]);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |