Submission #450439

#TimeUsernameProblemLanguageResultExecution timeMemory
450439nickmet2004구간 성분 (KOI15_interval)C++11
30 / 100
68 ms24888 KiB
#include<bits/stdc++.h> #define f first #define s second #define int long long using namespace std; const int N = 2005; int A = 37; int B = 1e9 + 9; string s , t; int pw1[27]; vector<int> a[N] , b[N]; main (){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> s >> t; int n = s.size() , m = t.size(); pw1[0] =1; for(int i = 1; i < 26; ++i) pw1[i] = pw1[i - 1] * A*(i + 1) % B; for(int i = 0; i < n; ++i){ int x= 0; for(int j = i; j < n; ++j){ x += pw1[s[j] - 'a']; if(x>=B)x-=B; a[j - i + 1].emplace_back(x); } } for(int i = 0; i < m; ++i){ int x= 0; for(int j = i; j < m; ++j){ x += pw1[t[j] - 'a']; if(x>=B)x-=B; b[j - i + 1].emplace_back(x); } } for(int i = min(n , m); ~i; --i){ sort(a[i].begin() , a[i].end()); sort(b[i].begin() , b[i].end()); int k = 0; for(int j= 0; j <a[i].size(); ++j){ while(a[i][j] > b[i][k] && k < b[i].size())++k; if(a[i][j] == b[i][k]){cout << i << endl; return 0;} } }cout << 0; }

Compilation message (stderr)

interval.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main (){
      | ^~~~
interval.cpp: In function 'int main()':
interval.cpp:38:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(int j= 0; j <a[i].size(); ++j){
      |                       ~~^~~~~~~~~~~~
interval.cpp:39:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             while(a[i][j] > b[i][k] && k < b[i].size())++k;
      |                                        ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...