## Submission #167508

# Submission time Handle Problem Language Result Execution time Memory
167508 2019-12-08T18:03:29 Z Thuleanx Lollipop (POI11_liz) C++14
100 / 100
539 ms 51088 KB
```#include <bits/stdc++.h>
using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int n, m; cin>>n>>m;
string s; cin>>s;

int p[n];
for (int i = 0; i < n; i++)
p[i] = (i?p[i-1]:0) + (s[i] == 'T' ? 2 : 1);
int st = 0, tt = n-1;
while (st < n && s[st] == 'T')
st++;
while (tt >= 0 && s[tt] == 'T')
tt--;

stringstream ss;
while (m--) {
int x; cin>>x;
if (p[n-1] - (st?p[st-1]:0) >= x) {
// always possible
int lo = st, hi = n-1;
int left = st?p[st-1]:0;
while (lo <= hi) {
int mid = lo+hi>>1;
if (p[mid] - left >= x)
hi = mid-1;
else lo = mid+1;
}
ss << st+1+(p[lo]-left>x) << " " << lo+1 << endl;
} else if (p[tt] >= x) {
// always possible
int lo = 0, hi = tt;
while (lo <= hi) {
int mid = lo+hi>>1;
if (p[tt] - (mid?p[mid-1]:0) >= x)
lo = mid+1;
else hi = mid-1;
}
ss << hi+1 << " " << tt + 1 - (p[tt] - (hi?p[hi-1]:0) > x) << endl;
} else {
// maybe not
int lo = 0, hi = n-1;
while (lo <= hi) {
int mid = lo+hi>>1;
if (p[mid] >= x) hi = mid-1;
else lo = mid+1;
}
if (p[lo] == x)
ss << 1 << " " << lo+1 << endl;
else
ss << "NIE" << endl;
}
}
cout << ss.str();

return 0;
}
```

### Compilation message

```liz.cpp: In function 'int main()':
liz.cpp:28:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid = lo+hi>>1;
~~^~~
liz.cpp:38:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid = lo+hi>>1;
~~^~~
liz.cpp:48:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid = lo+hi>>1;
~~^~~```

#### Subtask #1 8.0 / 8.0

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct

#### Subtask #2 8.0 / 8.0

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct

#### Subtask #3 8.0 / 8.0

# Verdict Execution time Memory Grader output
1 Correct 2 ms 412 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 9 ms 1020 KB Output is correct

#### Subtask #4 8.0 / 8.0

# Verdict Execution time Memory Grader output
1 Correct 6 ms 632 KB Output is correct
2 Correct 6 ms 760 KB Output is correct
3 Correct 6 ms 760 KB Output is correct

#### Subtask #5 8.0 / 8.0

# Verdict Execution time Memory Grader output
1 Correct 10 ms 1264 KB Output is correct
2 Correct 10 ms 1268 KB Output is correct
3 Correct 40 ms 4332 KB Output is correct

#### Subtask #6 8.0 / 8.0

# Verdict Execution time Memory Grader output
1 Correct 35 ms 4096 KB Output is correct
2 Correct 165 ms 14528 KB Output is correct
3 Correct 79 ms 8556 KB Output is correct

#### Subtask #7 8.0 / 8.0

# Verdict Execution time Memory Grader output
1 Correct 32 ms 3576 KB Output is correct
2 Correct 34 ms 3368 KB Output is correct
3 Correct 82 ms 8612 KB Output is correct

#### Subtask #8 8.0 / 8.0

# Verdict Execution time Memory Grader output
1 Correct 131 ms 10864 KB Output is correct
2 Correct 120 ms 11168 KB Output is correct
3 Correct 178 ms 17372 KB Output is correct

#### Subtask #9 9.0 / 9.0

# Verdict Execution time Memory Grader output
1 Correct 292 ms 28312 KB Output is correct
2 Correct 281 ms 27112 KB Output is correct
3 Correct 334 ms 32932 KB Output is correct

#### Subtask #10 9.0 / 9.0

# Verdict Execution time Memory Grader output
1 Correct 258 ms 24340 KB Output is correct
2 Correct 342 ms 30512 KB Output is correct
3 Correct 387 ms 35944 KB Output is correct

#### Subtask #11 9.0 / 9.0

# Verdict Execution time Memory Grader output
1 Correct 532 ms 48492 KB Output is correct
2 Correct 458 ms 45728 KB Output is correct
3 Correct 483 ms 43608 KB Output is correct

#### Subtask #12 9.0 / 9.0

# Verdict Execution time Memory Grader output
1 Correct 539 ms 51088 KB Output is correct
2 Correct 534 ms 40268 KB Output is correct
3 Correct 399 ms 46688 KB Output is correct