# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
26610 | model_code | 새로운 문제 (POI11_liz) | C11 | 2000 ms | 5996 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*************************************************************************
* *
* XVIII Olimpiada Informatyczna *
* *
* Zadanie: Lizak *
* Autor: Mateusz Baranowski *
* Zlozonosc czasowa: O(n * m * lg(n)) *
* pamieciowa: O(n) *
* Opis: Rozwiazanie powolne *
* Rozwiazanie przez bisekcje *
* *
*************************************************************************/
#include <stdio.h>
#define MAX_N 1000000
int n, m; /* ilosc segmentow lizaka i ilosc rozwazanych cen */
int sum[MAX_N + 1]; /* sum[i] cena fragmentu [1, i] */
int i, l, k;
int max[2]; /* najwieksza cena parzysta i nieparzysta */
int a, b, c; /* poczatek, koniec i srodek rozwazanego przedzialu */
int wa, wb; /* przedzial wynikowy */
char s[MAX_N + 1]; /* opis lizaka */
int main() {
scanf("%d %d", &n, &m);
scanf("%s", s);
sum[0] = 0;
for (i = 0; i < n; ++i)
if (s[i] == 'W')
sum[i + 1] = sum[i] + 1;
else
sum[i + 1] = sum[i] + 2;
for (i = 0; i < m ; ++i) {
scanf ("%d", &k);
wa = 0;
if (k <= sum[n]) {
l = 0;
while ((wa == 0) && (l < n)) {
/* przeszukiwanie binarne konca przedzialu dla poczatku l */
a = l;
b = n;
while (a < b) {
c = (a + b) / 2;
if (sum[c] - sum[l] < k)
a = c + 1;
else if (sum[c] - sum[l] > k)
b = c - 1;
else {
a = c;
b = c;
}
}
if (sum[a] - sum[l] == k) {
wa = l + 1;
wb = a;
}
++l;
}
}
if (wa != 0)
printf("%d %d\n", wa, wb);
else
printf("NIE\n");
}
return 0;
}
컴파일 시 표준 에러 (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... |
# | 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... |
# | 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... |