Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
109725 曾煦翔 01串排序 C++ 通过 100 0 MS 252 KB 767 2023-11-11 10:08:01

Tests(4/4):


#include <bits/stdc++.h> using namespace std; string a[55]; bool cmp(string x , string y) { int x1 = x.length(), y1 = y.length(); int x0 = 0, y0 = 0; if(x1 < y1) return true; else if(x1 == y1) { for(int i = 0;i < x1;i++) { if(x[i] == '1') x0++; } for(int i = 0;i < y1;i++) { if(y[i] == '1') y0++; } if(x0 < y0) return true; else if(x0 > y0) return false; else if(x < y) return true; else return false; } return false; } int main() { // freopen("strand.in" , "r" , stdin); // freopen("strand.out", "w" , stdout); int n; cin >> n; for(int i = 1;i <= n;i++) cin >> a[i]; sort(a + 1 , a + n + 1 , cmp); for(int i = 1;i <= n;i++) cout << a[i] << endl; return 0; }


测评信息: