Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
111070 李树强 递增子序列 C++ 输出格式错误 50 0 MS 252 KB 673 2023-11-18 09:51:51

Tests(1/2):


#include<iostream> #include<string> #include<set> using namespace std; set<string> st; int n, a[1010]; bool b[1010]; void f(int x = 0, int u = -114514, int l = 0){ if(x == n){ if(l < 2) return; string s = ""; for(int i = 0; i < n; i++) if(b[i]){ s += (a[i] + '0'); s += ' '; } s = s.substr(0, s.size() - 1); st.insert(s); return; } if(a[x] >= u) b[x] = 1; if(a[x] >= u) f(x + 1, a[x], l + 1); b[x] = 0; f(x + 1, u, l); } int main(){ cin >> n; for(int i = 0; i < n; i++){ cin >> a[i]; } f(); int ti = 0; for(auto t: st){ ti++; cout << t; if(ti < st.size()) cout << endl; } return 0; }


测评信息: