| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 318126 | gsh7013020 | 守序数 T4 | C++ | 通过 | 96 MS | 40708 KB | 1090 | 2026-04-19 17:09:24 |
#include <bits/stdc++.h> using namespace std; template<typename U, typename V>bool cmin(U &x, const V &y) { return y < x ? x = y, 1 : 0; } template<typename U, typename V>bool cmax(U &x, const V &y) { return y > x ? x = y, 1 : 0; } //不听老人言,磕到甲沟炎 using ll = long long; using pii = pair<int, int>; using ull = unsigned long long; #define fi first #define ls i<<1 #define rs i<<1|1 #define fls i>>1 #define frs i-1>>1 #define endl '\n' #define se second #define int ll const int N = 1e6 + 10, inf = 0x3f3f3f3f,mod=1e9+7; int n,c,a[N]; struct node{ int pre,val; }p,u; void solve() { queue<node>q; cin >> n; for (int i = 1;i <= 9;i++){ p.pre=i,p.val=i; q.push(p); } while(c<=n){ p=q.front(); q.pop(); a[++c]=p.val; for (int i = -1;i <= 1;i++){ u.pre=p.pre+i; u.val=p.val*10+u.pre; if (u.pre>=0&&u.pre<=9)q.push(u); } } sort(a+1,a+1+c); cout <<a[n]; } signed main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int T = 1; //cin >> T; while (T--) { solve(); } return 0; }