# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
118324 | 2019-06-18T16:17:30 Z | popovicirobert | Lollipop (POI11_liz) | C++14 | 810 ms | 35420 KB |
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long // 217 // 44 using namespace std; const int MAXN = (int) 1e6; int where[2 * MAXN + 1], sp[MAXN + 1]; char str[MAXN + 1]; int n; inline int find(int val) { int res = 0; for(int step = 1 << 19; step; step >>= 1) { if(res + step <= n && sp[res + step] <= val) { res += step; } } if(sp[res] != val) res = -1; return res; } int main() { //ifstream cin("B.in"); //ofstream cout("B.out"); int i, m; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> m >> str + 1; int pos = -1; for(i = 1; i <= n; i++) { sp[i] = sp[i - 1]; if(str[i] == 'W') { if(pos == -1) { pos = i; } sp[i]++; } else { sp[i] += 2; } where[sp[i]] = i; } vector <int> sums[2]; if(pos != -1) { for(i = pos; i <= n; i++) { int cur = sp[i] - sp[pos - 1]; sums[cur & 1].push_back(cur); } } while(m--) { int x; cin >> x; if(sp[n] < x) { cout << "NIE\n"; continue; } if(where[x] > 0) { cout << 1 << " " << where[x] << "\n"; continue; } if(pos != -1) { int r = find(sp[pos] + x); if(r != -1) { cout << pos + 1 << " " << r << "\n"; continue; } r = find(sp[pos - 1] + x); if(r != -1) { cout << pos << " " << r << "\n"; continue; } r = upper_bound(sums[x & 1].begin(), sums[x & 1].end(), x) - sums[x & 1].begin(); if(sums[x & 1].size() && r > 0 && sums[x & 1][r - 1] + 2 * (pos - 1) >= x) { cout << pos - (x - sums[x & 1][r - 1]) / 2 << " " << r - 1 << "\n"; continue; } } cout << "NIE\n"; } //cin.close(); //cout.close(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Incorrect | 2 ms | 384 KB | Oczekiwano przedzialu o koszcie 113 otrzymano przedzial wartosci 38 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Incorrect | 7 ms | 640 KB | Oczekiwano przedzialu o koszcie 3461 otrzymano przedzial wartosci 1456 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 640 KB | Oczekiwano przedzialu o koszcie 9076 otrzymano przedzial wartosci 4584 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1152 KB | Oczekiwano przedzialu o koszcie 39257 otrzymano przedzial wartosci 18557 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 2560 KB | Output is correct |
2 | Correct | 115 ms | 6776 KB | Output is correct |
3 | Correct | 60 ms | 4344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 2860 KB | Output is correct |
2 | Correct | 23 ms | 2656 KB | Output is correct |
3 | Incorrect | 74 ms | 5000 KB | Oczekiwano przedzialu o koszcie 82063 otrzymano przedzial wartosci 2352 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 131 ms | 6740 KB | Output is correct |
2 | Incorrect | 132 ms | 6140 KB | Oczekiwano przedzialu o koszcie 144664 otrzymano przedzial wartosci 69670 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 345 ms | 16008 KB | Output is correct |
2 | Incorrect | 323 ms | 15328 KB | Oczekiwano przedzialu o koszcie 515579 otrzymano przedzial wartosci 243278 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 329 ms | 17424 KB | Output is correct |
2 | Correct | 392 ms | 19184 KB | Output is correct |
3 | Incorrect | 513 ms | 23608 KB | Oczekiwano przedzialu o koszcie 687076 otrzymano przedzial wartosci 79948 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 810 ms | 33848 KB | Output is correct |
2 | Incorrect | 498 ms | 31708 KB | Oczekiwano przedzialu o koszcie 1412076 otrzymano przedzial wartosci 703201 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 710 ms | 35420 KB | Oczekiwano przedzialu o koszcie 1896583 otrzymano przedzial wartosci 935302 |
2 | Halted | 0 ms | 0 KB | - |