Submission #771419

#TimeUsernameProblemLanguageResultExecution timeMemory
771419gggkik영역 (JOI16_ho_t4)C++14
15 / 100
30 ms5116 KiB
#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;
}

Compilation message (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...