Submission #321008

# Submission time Handle Problem Language Result Execution time Memory
321008 2020-11-10T15:51:03 Z tjdgus4384 구간 성분 (KOI15_interval) C++14
31 / 100
421 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 = 1;i <= s1.size();i++){
        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 i = s2.size();i > 0;i--){
        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 < s1.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:9:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i = 1;i <= s1.size();i++){
      |                   ~~^~~~~~~~~~~~
interval.cpp:14:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         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 < s1.size();j++){
      |                       ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Incorrect 1 ms 492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 59 ms 14696 KB Output is correct
2 Incorrect 67 ms 18404 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 397 ms 86884 KB Output is correct
2 Correct 421 ms 89572 KB Output is correct
3 Correct 383 ms 88676 KB Output is correct
4 Correct 373 ms 86756 KB Output is correct
5 Correct 392 ms 89700 KB Output is correct
6 Correct 377 ms 87268 KB Output is correct
7 Correct 401 ms 89700 KB Output is correct
8 Correct 392 ms 89700 KB Output is correct
9 Correct 399 ms 89700 KB Output is correct
10 Correct 394 ms 89316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 219 ms 34660 KB Output is correct
2 Runtime error 419 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -