Submission #40030

# Submission time Handle Problem Language Result Execution time Memory
40030 2018-01-25T11:57:02 Z funcsr 구간 성분 (KOI15_interval) C++14
30 / 100
237 ms 15440 KB
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD (1000000009LL*1000000007LL)
const int B = 2111;

vector<long long> mp[1501];
string S, T;
long long pB[26];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  pB[0] = 1;
  for (int i=1; i<26; i++) pB[i] = (1LL*B*pB[i-1]) % MOD;
  cin >> S >> T;
  rep(l, S.size()) {
    long long cnt = 0;
    for (int r=l; r<S.size(); r++) {
      cnt = (cnt + pB[S[r]-'a']) % MOD;
      mp[r-l+1].pb(cnt);
    }
  }
  rep(i, 1501) sort(all(mp[i])), uniq(mp[i]);
  int m = 0;
  rep(l, T.size()) {
    long long cnt = 0;
    for (int r=l; r<T.size(); r++) {
      cnt = (cnt + pB[T[r]-'a']) % MOD;
      if (binary_search(all(mp[r-l+1]), cnt)) m = max(m, r-l+1);
    }
  }
  cout << m << "\n";
  return 0;
}

Compilation message

interval.cpp: In function 'int main()':
interval.cpp:17:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i, n) for (int i=0; i<(n); i++)
                                  ^
interval.cpp:36:3: note: in expansion of macro 'rep'
   rep(l, S.size()) {
   ^
interval.cpp:38:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int r=l; r<S.size(); r++) {
                    ^
interval.cpp:17:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i, n) for (int i=0; i<(n); i++)
                                  ^
interval.cpp:45:3: note: in expansion of macro 'rep'
   rep(l, T.size()) {
   ^
interval.cpp:47:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int r=l; r<T.size(); r++) {
                    ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2216 KB Output is correct
2 Correct 0 ms 2216 KB Output is correct
3 Correct 0 ms 2216 KB Output is correct
4 Correct 1 ms 2216 KB Output is correct
5 Correct 1 ms 2216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 3140 KB Output is correct
2 Correct 14 ms 3536 KB Output is correct
3 Correct 4 ms 3536 KB Output is correct
4 Correct 5 ms 3536 KB Output is correct
5 Correct 18 ms 3536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 7548 KB Output is correct
2 Correct 96 ms 7548 KB Output is correct
3 Correct 104 ms 7548 KB Output is correct
4 Correct 103 ms 7548 KB Output is correct
5 Correct 98 ms 7548 KB Output is correct
6 Correct 100 ms 7548 KB Output is correct
7 Correct 108 ms 7548 KB Output is correct
8 Correct 101 ms 7548 KB Output is correct
9 Correct 102 ms 7548 KB Output is correct
10 Incorrect 104 ms 7548 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 10588 KB Output is correct
2 Incorrect 237 ms 15440 KB Output isn't correct
3 Halted 0 ms 0 KB -