# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
993423 | Phuocbua | K-th path (IZhO11_kthpath) | C++17 | 0 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int phu_ho_di(int m, int n) {
return static_cast<int>(tgamma(max(m, n) + 1) / (tgamma(min(m, n) + 1) * tgamma(max(m, n) - min(m, n) + 1)));
}
int phu_ho_cac_cu_moi_ngay(int m, int n) {
return phu_ho_di(m + n - 2, n - 1);
}
int main() {
int b, a;
cin >> b >> a;
vector<vector<char>> arr(b);
for (int i = 0; i < b; i++) {
string row;
cin >> row;
arr[i] = vector<char>(row.begin(), row.end());
}
int k;
cin >> k;
int ptr_x = 0, ptr_y = 0;
string str = "";
int nt = 1;
while (ptr_x < b && ptr_y < a) {
str += arr[ptr_x][ptr_y];
if (ptr_x == b - 1) {
ptr_y++;
} else if (ptr_y == a - 1) {
ptr_x++;
} else {
if (arr[ptr_x + 1][ptr_y] > arr[ptr_x][ptr_y + 1]) {
if (nt + phu_ho_cac_cu_moi_ngay(b - ptr_x, a - ptr_y - 1) <= k) {
nt += phu_ho_cac_cu_moi_ngay(b - ptr_x, a - ptr_y - 1);
ptr_x++;
} else {
ptr_y++;
}
} else {
if (nt + phu_ho_cac_cu_moi_ngay(b - ptr_x - 1, a - ptr_y) <= 1) {
nt += phu_ho_cac_cu_moi_ngay(b - ptr_x - 1, a - ptr_y);
ptr_y++;
} else {
ptr_x++;
}
}
}
}
cout << str << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |