Compare commits

..

No commits in common. "797976b8533dc506640e18735297331f91402c44" and "d9a9164d21da4ad9527ab7ac14763a5f04499e82" have entirely different histories.

2 changed files with 35 additions and 95 deletions

View File

@ -1,59 +0,0 @@
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>
using ll = int64_t;
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::vector<ll> v;
v.reserve(100000);
ll tmp;
while (std::cin >> tmp) {
v.push_back(tmp);
}
if (v.empty()) {
std::cout << "0\n0\n";
return 0;
}
std::vector<ll> f(v.size() + 1, 0);
f[1] = v[0];
ll maxdp = 1;
for (ll i = 1; i < v.size(); i++) {
ll h = v[i];
ll l = 1, r = maxdp, ans = 0;
while (l <= r) {
ll mid = (l + r) >> 1;
if (f[mid] >= h) {
ans = mid;
l = mid + 1;
} else {
r = mid - 1;
}
}
if (ans == 0) {
f[1] = std::max(f[1], h);
} else {
ll nxt = ans + 1;
if (nxt > maxdp) {
maxdp = nxt;
f[nxt] = h;
} else {
f[nxt] = std::max(f[nxt], h);
}
}
}
std::cout << maxdp << '\n';
std::vector<ll> sys;
sys.reserve(v.size());
for (ll h : v) {
auto it = std::lower_bound(sys.begin(), sys.end(), h);
if (it == sys.end()) sys.push_back(h);
else *it = h;
}
std::cout << sys.size() << '\n';
return 0;
}

View File

@ -1,41 +1,40 @@
#include <iostream> #include <vector>
using namespace std; using namespace std;
const int N = 1000; class Solution {
int c[N]; public:
vector<int> findDiagonalOrder(const vector<vector<int>>& m) {
int logic(int x, int y) { int x=0,y=0;
return (x & y) ^ ((x ^ y) | (~x & y)); bool isup=true;
} vector<int> res;
res.reserve(m.size());
void generate(int a, int b, int *c) { #define isout (x<0||x>m.size()||y<0||y>m[0].size())
for (int i = 0; i < b; i++) do{
c[i] = logic(a, i) % (b + 1); res.push_back(m[x][y]);
} if(isup){
if(x==0){
void recursion(int depth, int *arr, int size) { ++y;
if (depth <= 0 || size <= 1) return; isup=false;
int pivot = arr[0]; }else{
int i = 0, j = size - 1; --x;
while (i <= j) { ++y;
while (arr[i] < pivot) i++; }
while (arr[j] > pivot) j--; }else{
if (i <= j) { if(y==0){
int temp = arr[i]; ++x;
arr[i] = arr[j]; isup=true;
arr[j] = temp; }else{
i++; j--; ++x;
--y;
} }
} }
recursion(depth - 1, arr, j + 1); }while(!(x==m.size()&&y==m[0].size()));
recursion(depth - 1, arr + i, size - i); return res;
} }
};
int main() { int main(){
int a, b, d;
cin >> a >> b >> d; Solution s;
generate(a, b, c); s.findDiagonalOrder({{1,2,3},{4,5,6},{7,8,9}});
recursion(d, c, b);
for (int i = 0; i < b; ++i) cout << c[i] << " ";
cout << endl;
} }