답안 #51644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51644 2018-06-19T13:36:31 Z okaybody10 구간 성분 (KOI15_interval) C++
61 / 100
1000 ms 171900 KB
#include <iostream>
#include <vector>
#include <set>
#include <string.h>
#pragma GCC optimize(Ofast)
using namespace std;
typedef vector<int> vi;
set<vi> gg;
int main()
{
    char s1[1605],s2[1605];
    scanf("%s %s",s1,s2);
    int l1=strlen(s1),l2=strlen(s2);
    for(int i=l1;i>0;i--)
    {
        vi alpha(26);
        int s=0,e=i-1;
        for(int j=s;j<=e;j++) alpha[s1[j]-'a']++;
        while(e<l1)
        {
            gg.insert(alpha);
            if(++e<l1) alpha[s1[e]-'a']++,alpha[s1[s++]-'a']--;
        }
    }
    for(int i=l2;i>0;i--)
    {
        vi alpha(26);
        int s=0,e=i-1;
        for(int j=s;j<=e;j++) alpha[s2[j]-'a']++;
        while(e<l2)
        {
            if(gg.find(alpha) != gg.end()) { return !printf("%d",i);}
            if(++e<l2) alpha[s2[e]-'a']++,alpha[s2[s++]-'a']--;
        }
    }
    printf("0");
    return 0;
}

Compilation message

interval.cpp:5:22: warning: '#pragma GCC optimize' is not a string or number [-Wpragmas]
 #pragma GCC optimize(Ofast)
                      ^~~~~
interval.cpp: In function 'int main()':
interval.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s %s",s1,s2);
     ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 6 ms 1176 KB Output is correct
5 Correct 7 ms 1176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 120 ms 13524 KB Output is correct
2 Correct 82 ms 16980 KB Output is correct
3 Correct 26 ms 16980 KB Output is correct
4 Correct 13 ms 16980 KB Output is correct
5 Correct 131 ms 20028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 569 ms 79548 KB Output is correct
2 Correct 524 ms 82512 KB Output is correct
3 Correct 505 ms 82512 KB Output is correct
4 Correct 523 ms 82512 KB Output is correct
5 Correct 519 ms 82632 KB Output is correct
6 Correct 519 ms 82632 KB Output is correct
7 Correct 534 ms 82632 KB Output is correct
8 Correct 569 ms 82632 KB Output is correct
9 Correct 497 ms 82632 KB Output is correct
10 Correct 597 ms 82632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 280 ms 82632 KB Output is correct
2 Execution timed out 1091 ms 171900 KB Time limit exceeded
3 Halted 0 ms 0 KB -