답안 #321010

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321010 2020-11-10T15:55:30 Z tjdgus4384 구간 성분 (KOI15_interval) C++14
61 / 100
521 ms 131076 KB
#include<bits/stdc++.h>
using namespace std;
string s1, s2;
vector<int> v(30, 0), t(30, 0);
set<vector<int> > s;

int main(){
    cin >> s1 >> s2;
    for(int i = s1.size();i > 0;i--){
        if(i > s2.size()) continue;
        for(int j = 0;j < i;j++){
            v[s1[j]-'a']++;
        }
        s.insert(v);
        for(int j = i;j < s1.size();j++){
            v[s1[j-i]-'a']--;
            v[s1[j]-'a']++;
            s.insert(v);
        }
        for(int j = 0;j < 30;j++) v[j] = 0;

        for(int j = 0;j < i;j++){
            t[s2[j]-'a']++;
        }
        if(s.count(t)){
            printf("%d", i); return 0;
        }
        for(int j = i;j < s2.size();j++){
            t[s2[j-i]-'a']--;
            t[s2[j]-'a']++;
            if(s.count(t)){
                printf("%d", i); return 0;
            }
        }
        for(int j = 0;j < 30;j++) t[j] = 0;
    }
    printf("0");
    return 0;
}

Compilation message

interval.cpp: In function 'int main()':
interval.cpp:10:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |         if(i > s2.size()) continue;
      |            ~~^~~~~~~~~~~
interval.cpp:15:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for(int j = i;j < s1.size();j++){
      |                       ~~^~~~~~~~~~~
interval.cpp:28:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int j = i;j < s2.size();j++){
      |                       ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 3 ms 1132 KB Output is correct
5 Correct 3 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 14564 KB Output is correct
2 Correct 52 ms 13412 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 90 ms 21092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 387 ms 83936 KB Output is correct
2 Correct 410 ms 89060 KB Output is correct
3 Correct 414 ms 88296 KB Output is correct
4 Correct 399 ms 85680 KB Output is correct
5 Correct 401 ms 88932 KB Output is correct
6 Correct 373 ms 85988 KB Output is correct
7 Correct 419 ms 88956 KB Output is correct
8 Correct 410 ms 88292 KB Output is correct
9 Correct 393 ms 89040 KB Output is correct
10 Correct 406 ms 88548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 8036 KB Output is correct
2 Runtime error 521 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -