# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
485298 |
2021-11-07T03:52:48 Z |
xiaowuc1 |
구간 성분 (KOI15_interval) |
C++17 |
|
388 ms |
664 KB |
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;
// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
typedef vector<int> vi;
#define f first
#define s second
#define derr if(1) cerr
// END NO SAD
template<class Fun>
class y_combinator_result {
Fun fun_;
public:
template<class T>
explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}
template<class ...Args>
decltype(auto) operator()(Args &&...args) {
return fun_(std::ref(*this), std::forward<Args>(args)...);
}
};
template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> matrix;
void solve() {
string a, b;
cin >> a >> b;
auto genhash = [&](const string& s, int len, vector<vector<int>>& f) {
vector<int> amt(26);
for(int i = 0; i < sz(s); i++) {
amt[s[i]-'a']++;
if(i >= len) amt[s[i-len]-'a']--;
if(i >= len - 1) f.pb(amt);
}
};
int ret = min(sz(a), sz(b));
while(ret > 0) {
vector<vector<int>> av, bv;
genhash(a, ret, av);
genhash(b, ret, bv);
sort(all(av));
sort(all(bv));
int i = 0;
int j = 0;
bool found = false;
while(i < sz(av) && j < sz(bv) && !found) {
if(av[i] == bv[j]) found = true;
else if(av[i] < bv[j]) i++;
else j++;
}
if(found) {
cout << ret << "\n";
return;
}
ret--;
}
cout << ret << "\n";
}
// what would chika do
// are there edge cases (N=1?)
// are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// integer overflow?
// DS reset properly between test cases
// are you doing geometry in floating points
// are you not using modint when you should
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
344 KB |
Output is correct |
2 |
Correct |
24 ms |
388 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
42 ms |
420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
166 ms |
532 KB |
Output is correct |
2 |
Correct |
172 ms |
560 KB |
Output is correct |
3 |
Correct |
183 ms |
580 KB |
Output is correct |
4 |
Correct |
168 ms |
544 KB |
Output is correct |
5 |
Correct |
169 ms |
556 KB |
Output is correct |
6 |
Correct |
165 ms |
552 KB |
Output is correct |
7 |
Correct |
176 ms |
580 KB |
Output is correct |
8 |
Correct |
169 ms |
508 KB |
Output is correct |
9 |
Correct |
174 ms |
452 KB |
Output is correct |
10 |
Correct |
172 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
468 KB |
Output is correct |
2 |
Correct |
336 ms |
644 KB |
Output is correct |
3 |
Correct |
299 ms |
664 KB |
Output is correct |
4 |
Correct |
22 ms |
568 KB |
Output is correct |
5 |
Correct |
388 ms |
636 KB |
Output is correct |