# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
443770 |
2021-07-12T04:25:33 Z |
xiaowuc1 |
None (KOI18_matrix) |
C++17 |
|
425 ms |
27356 KB |
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#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
// END NO SAD
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> matrix;
void threesolve(int n) {
vector<array<int, 3>> v(n);
for(int i = 0; i < 3; i++) {
vector<int> vals;
vector<int> sorted;
for(int a = 0; a < n; a++) {
int x;
cin >> x;
vals.pb(x);
sorted.pb(x);
}
sort(all(sorted));
for(auto& x: vals) x = lb(all(sorted), x) - sorted.begin();
for(int a = 0; a < n; a++) v[a][i] = vals[a];
}
sort(all(v));
vector<set<pii>> dp(n+1);
int ret = 0;
for(auto out: v) {
pii key = {out[1], out[2]};
int lhs = 0;
int rhs = ret;
while(lhs < rhs) {
int mid = (lhs+rhs+1)/2;
auto it = dp[mid].lb(key);
if(it == dp[mid].begin()) {
rhs = mid-1;
continue;
}
it--;
if(key.s > it->s) lhs = mid;
else rhs = mid - 1;
}
ret = max(ret, lhs+1);
lhs++;
while(true) {
auto it = dp[lhs].lb(key);
if(it == dp[lhs].end()) break;
if(it->s <= key.s) break;
dp[lhs].erase(it);
}
dp[lhs].insert(key);
}
cout << ret << "\n";
}
void twosolve(int n) {
vector<array<int, 2>> v(n);
for(int i = 0; i < 2; i++) {
vector<int> vals;
vector<int> sorted;
for(int a = 0; a < n; a++) {
int x;
cin >> x;
vals.pb(x);
sorted.pb(x);
}
sort(all(sorted));
for(auto& x: vals) x = lb(all(sorted), x) - sorted.begin();
for(int a = 0; a < n; a++) v[a][i] = vals[a];
}
sort(all(v));
vector<int> dp(n+1);
int ret = 0;
for(int i = 0; i < n; i++) {
int lhs = 0;
int rhs = ret;
while(lhs < rhs) {
int mid = (lhs+rhs+1)/2;
if(v[i][1] > v[dp[mid]][1]) lhs = mid;
else rhs = mid-1;
}
ret = max(ret, lhs+1);
dp[++lhs] = i;
}
cout << ret << "\n";
}
void solve() {
int r, c;
cin >> r >> c;
if(r == 2) twosolve(c);
else threesolve(c);
}
// 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
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
520 KB |
Output is correct |
2 |
Correct |
8 ms |
544 KB |
Output is correct |
3 |
Correct |
8 ms |
544 KB |
Output is correct |
4 |
Correct |
7 ms |
544 KB |
Output is correct |
5 |
Correct |
8 ms |
544 KB |
Output is correct |
6 |
Correct |
7 ms |
560 KB |
Output is correct |
7 |
Correct |
8 ms |
544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
1400 KB |
Output is correct |
2 |
Correct |
13 ms |
1468 KB |
Output is correct |
3 |
Correct |
14 ms |
1372 KB |
Output is correct |
4 |
Correct |
15 ms |
1212 KB |
Output is correct |
5 |
Correct |
13 ms |
1372 KB |
Output is correct |
6 |
Correct |
12 ms |
1596 KB |
Output is correct |
7 |
Correct |
19 ms |
1240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
520 KB |
Output is correct |
2 |
Correct |
8 ms |
544 KB |
Output is correct |
3 |
Correct |
8 ms |
544 KB |
Output is correct |
4 |
Correct |
7 ms |
544 KB |
Output is correct |
5 |
Correct |
8 ms |
544 KB |
Output is correct |
6 |
Correct |
7 ms |
560 KB |
Output is correct |
7 |
Correct |
8 ms |
544 KB |
Output is correct |
8 |
Correct |
195 ms |
4780 KB |
Output is correct |
9 |
Correct |
186 ms |
4784 KB |
Output is correct |
10 |
Correct |
180 ms |
4748 KB |
Output is correct |
11 |
Correct |
201 ms |
4808 KB |
Output is correct |
12 |
Correct |
178 ms |
4744 KB |
Output is correct |
13 |
Correct |
178 ms |
4852 KB |
Output is correct |
14 |
Correct |
183 ms |
4752 KB |
Output is correct |
15 |
Correct |
170 ms |
4820 KB |
Output is correct |
16 |
Correct |
188 ms |
4744 KB |
Output is correct |
17 |
Correct |
178 ms |
4816 KB |
Output is correct |
18 |
Correct |
205 ms |
4780 KB |
Output is correct |
19 |
Correct |
177 ms |
4736 KB |
Output is correct |
20 |
Correct |
186 ms |
4872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
1400 KB |
Output is correct |
2 |
Correct |
13 ms |
1468 KB |
Output is correct |
3 |
Correct |
14 ms |
1372 KB |
Output is correct |
4 |
Correct |
15 ms |
1212 KB |
Output is correct |
5 |
Correct |
13 ms |
1372 KB |
Output is correct |
6 |
Correct |
12 ms |
1596 KB |
Output is correct |
7 |
Correct |
19 ms |
1240 KB |
Output is correct |
8 |
Correct |
324 ms |
22176 KB |
Output is correct |
9 |
Correct |
310 ms |
20908 KB |
Output is correct |
10 |
Correct |
308 ms |
24728 KB |
Output is correct |
11 |
Correct |
279 ms |
27356 KB |
Output is correct |
12 |
Correct |
289 ms |
17952 KB |
Output is correct |
13 |
Correct |
310 ms |
23584 KB |
Output is correct |
14 |
Correct |
355 ms |
20108 KB |
Output is correct |
15 |
Correct |
289 ms |
24084 KB |
Output is correct |
16 |
Correct |
293 ms |
24252 KB |
Output is correct |
17 |
Correct |
337 ms |
20964 KB |
Output is correct |
18 |
Correct |
425 ms |
18200 KB |
Output is correct |
19 |
Correct |
269 ms |
17988 KB |
Output is correct |
20 |
Correct |
351 ms |
21044 KB |
Output is correct |
21 |
Correct |
289 ms |
24156 KB |
Output is correct |
22 |
Correct |
393 ms |
18804 KB |
Output is correct |
23 |
Correct |
320 ms |
21180 KB |
Output is correct |
24 |
Correct |
276 ms |
17956 KB |
Output is correct |
25 |
Correct |
419 ms |
19300 KB |
Output is correct |
26 |
Correct |
393 ms |
27320 KB |
Output is correct |
27 |
Correct |
270 ms |
18100 KB |
Output is correct |
28 |
Correct |
301 ms |
24368 KB |
Output is correct |
29 |
Correct |
319 ms |
20912 KB |
Output is correct |
30 |
Correct |
319 ms |
20932 KB |
Output is correct |
31 |
Correct |
416 ms |
27224 KB |
Output is correct |
32 |
Correct |
313 ms |
20880 KB |
Output is correct |