# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
20885 | 14kg | 구간 성분 (KOI15_interval) | C++11 | 796 ms | 1660 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <string.h>
#include <map>
using namespace std;
struct STRING {
int cnt[27];
bool operator<(const STRING &t) const {
for (int i = 1; i <= 26; i++)
if (cnt[i] != t.cnt[i]) return cnt[i] < t.cnt[i];
return false;
}
void clear() {
for (int i = 1; i <= 26; i++) cnt[i] = 0;
}
};
int a_len, b_len, a[1501], b[1501];
map<STRING, bool> M;
int input(int *in) {
int len;
char temp[1510];
scanf("%s", temp + 1), len = strlen(temp + 1);
for (int i = 1; i <= len; i++) in[i] = temp[i] - 'a' + 1;
return len;
}
int main() {
STRING temp;
a_len = input(a), b_len = input(b);
for (int L = (a_len < b_len ? a_len : b_len); L >= 1; L--) {
M.clear(), temp.clear();
for (int i = 1; i < L; i++) temp.cnt[a[i]]++;
for (int i = 1; i <= a_len - L + 1; i++) {
temp.cnt[a[i - 1]]--, temp.cnt[a[i + L - 1]]++;
M[temp] = true;
}
temp.clear();
for (int i = 1; i < L; i++) temp.cnt[b[i]]++;
for (int i = 1; i <= b_len - L + 1; i++) {
temp.cnt[b[i - 1]]--, temp.cnt[b[i + L - 1]]++;
if (M[temp]) { printf("%d", L); return 0; }
}
} printf("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... |