Submission #137103

#TimeUsernameProblemLanguageResultExecution timeMemory
137103arnold518영역 (JOI16_ho_t4)C++14
38 / 100
1076 ms17448 KiB
#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>50 && 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]); }

Compilation message (stderr)

2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:48:24: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}' [-Wformat=]
     printf("%lld", V[K]);
                        ^
2016_ho_t4.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%s", &N, &K, S+1);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...