답안 #18115

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18115 2016-01-21T06:14:59 Z chan492811 구간 성분 (KOI15_interval) C++
100 / 100
522 ms 1716 KB
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int n,m,res;
char arr1[1510],arr2[1510];
vector<int> vt(26);
set <vector <int> > st;
void vector_init(){
    int i;
    for(i=0;i<26;i++) vt[i]=0;
}
void init(int a){
    int i;
    for(i=0;i<a;i++) vt[arr1[i]-'a']++; st.insert(vt);
    for(;i<n;i++){
        vt[arr1[i]-'a']++; vt[arr1[i-a]-'a']--; st.insert(vt);
    }
}
void iscan(int a){
    int i;
    for(i=0;i<a;i++) vt[arr2[i]-'a']++; if(st.find(vt)!=st.end()){ res=a; return; }
    for(;i<m;i++){
        vt[arr2[i]-'a']++; vt[arr2[i-a]-'a']--;
        if(st.find(vt)!=st.end()){ res=a; return; }
    }
}
int main(){
    int i,j;
    scanf("%s %s",arr1,arr2); n=strlen(arr1); m=strlen(arr2);
    for(i=1;i<=min(n,m);i++){
        init(i); vector_init();
        iscan(i); vector_init();
        st.clear();
    }
    printf("%d",res);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1584 KB Output is correct
2 Correct 0 ms 1584 KB Output is correct
3 Correct 1 ms 1584 KB Output is correct
4 Correct 2 ms 1584 KB Output is correct
5 Correct 0 ms 1584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 1584 KB Output is correct
2 Correct 39 ms 1584 KB Output is correct
3 Correct 15 ms 1584 KB Output is correct
4 Correct 12 ms 1584 KB Output is correct
5 Correct 47 ms 1584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 218 ms 1716 KB Output is correct
2 Correct 232 ms 1716 KB Output is correct
3 Correct 222 ms 1716 KB Output is correct
4 Correct 217 ms 1716 KB Output is correct
5 Correct 225 ms 1716 KB Output is correct
6 Correct 220 ms 1716 KB Output is correct
7 Correct 224 ms 1716 KB Output is correct
8 Correct 214 ms 1716 KB Output is correct
9 Correct 226 ms 1716 KB Output is correct
10 Correct 226 ms 1716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 145 ms 1584 KB Output is correct
2 Correct 471 ms 1716 KB Output is correct
3 Correct 457 ms 1716 KB Output is correct
4 Correct 225 ms 1584 KB Output is correct
5 Correct 522 ms 1716 KB Output is correct