Submission #38443

# Submission time Handle Problem Language Result Execution time Memory
38443 2018-01-04T07:16:17 Z kajebiii 구간 성분 (KOI15_interval) C++14
100 / 100
513 ms 2288 KB
#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e3 + 10;

typedef unsigned int ui;

int N, M; char Ns[MAX_N], Ms[MAX_N];
int main() {
	scanf("%s", Ns); N = strlen(Ns);
	scanf("%s", Ms); M = strlen(Ms);

	int ans = 0;
	for(int l=min(N, M); l>=1; l--) {
		vector<int> n(26, 0), m(26, 0);
		for(int i=0; i<l-1; i++) n[Ns[i]-'a']++, m[Ms[i]-'a']++;
		set<vector<int>> s;
		for(int i=l-1; i<N; i++) {
			n[Ns[i]-'a']++;
			if(i-l>=0) n[Ns[i-l]-'a']--;
			s.insert(n);
		}
		for(int j=l-1; j<M; j++) {
			m[Ms[j]-'a']++;
			if(j-l>=0) m[Ms[j-l]-'a']--;
			if(s.find(m) != s.end()) {
				ans = l;
				goto finish;
			}
		}
	}
finish:
	printf("%d\n", ans);
	return 0;
}

Compilation message

interval.cpp: In function 'int main()':
interval.cpp:20:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", Ns); N = strlen(Ns);
                 ^
interval.cpp:21:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", Ms); M = strlen(Ms);
                 ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Correct 0 ms 2024 KB Output is correct
4 Correct 0 ms 2024 KB Output is correct
5 Correct 0 ms 2024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 2156 KB Output is correct
2 Correct 29 ms 2156 KB Output is correct
3 Correct 0 ms 2024 KB Output is correct
4 Correct 0 ms 2024 KB Output is correct
5 Correct 43 ms 2156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 206 ms 2156 KB Output is correct
2 Correct 196 ms 2156 KB Output is correct
3 Correct 193 ms 2156 KB Output is correct
4 Correct 199 ms 2156 KB Output is correct
5 Correct 219 ms 2156 KB Output is correct
6 Correct 213 ms 2156 KB Output is correct
7 Correct 206 ms 2156 KB Output is correct
8 Correct 203 ms 2156 KB Output is correct
9 Correct 246 ms 2156 KB Output is correct
10 Correct 239 ms 2156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 2024 KB Output is correct
2 Correct 409 ms 2288 KB Output is correct
3 Correct 396 ms 2288 KB Output is correct
4 Correct 16 ms 2024 KB Output is correct
5 Correct 513 ms 2288 KB Output is correct