Submission #22281196


Source Code Expand

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N;
string S[101010];
using T = tuple<string, int, string>;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> S[i];

	vector<T> sorted;
	rep(i, 0, N) {
		string s = S[i];

		int leadingZero = 0;
		int len = S[i].length();
		rep(j, 0, len - 1) {
			if (S[i][j] == '0') leadingZero++;
			else break;
		}

		sorted.push_back({ S[i].substr(leadingZero), leadingZero, S[i] });
	}

	sort(all(sorted), [&](T a, T b) {
		if (get<0>(a).length() != get<0>(b).length()) return get<0>(a).length() < get<0>(b).length();
		if (get<0>(a) != get<0>(b)) return get<0>(a) < get<0>(b);
		return get<1>(a) > get<1>(b);
	});

	fore(t, sorted) printf("%s\n", get<2>(t).c_str());
}





Submission Info

Submission Time
Task D - Leading Zeros
User hamayanhamayan
Language C++ (GCC 9.2.1)
Score 7
Code Size 2079 Byte
Status AC
Exec Time 68 ms
Memory 15852 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 7 / 7
Status
AC × 2
AC × 44
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_81.txt, random_82.txt, random_83.txt, random_84.txt, random_85.txt, random_86.txt, random_91.txt, random_92.txt, random_93.txt, random_94.txt, random_95.txt, random_96.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
random_01.txt AC 68 ms 15760 KiB
random_02.txt AC 66 ms 15776 KiB
random_03.txt AC 65 ms 15852 KiB
random_04.txt AC 37 ms 11220 KiB
random_05.txt AC 40 ms 11140 KiB
random_06.txt AC 39 ms 11160 KiB
random_07.txt AC 38 ms 11268 KiB
random_08.txt AC 41 ms 11224 KiB
random_09.txt AC 40 ms 11212 KiB
random_10.txt AC 37 ms 11196 KiB
random_11.txt AC 40 ms 11092 KiB
random_12.txt AC 18 ms 7628 KiB
random_13.txt AC 16 ms 7592 KiB
random_14.txt AC 23 ms 7676 KiB
random_15.txt AC 17 ms 7628 KiB
random_16.txt AC 16 ms 7688 KiB
random_17.txt AC 20 ms 7672 KiB
random_18.txt AC 22 ms 7636 KiB
random_19.txt AC 15 ms 7536 KiB
random_20.txt AC 15 ms 7220 KiB
random_21.txt AC 21 ms 7116 KiB
random_22.txt AC 14 ms 7148 KiB
random_23.txt AC 16 ms 7220 KiB
random_24.txt AC 20 ms 7120 KiB
random_25.txt AC 18 ms 7136 KiB
random_26.txt AC 18 ms 7112 KiB
random_27.txt AC 7 ms 6992 KiB
random_28.txt AC 6 ms 7124 KiB
random_29.txt AC 7 ms 7108 KiB
random_30.txt AC 8 ms 6972 KiB
random_81.txt AC 68 ms 15692 KiB
random_82.txt AC 40 ms 11140 KiB
random_83.txt AC 19 ms 7764 KiB
random_84.txt AC 22 ms 7256 KiB
random_85.txt AC 12 ms 7116 KiB
random_86.txt AC 9 ms 6916 KiB
random_91.txt AC 62 ms 15724 KiB
random_92.txt AC 33 ms 11136 KiB
random_93.txt AC 14 ms 7672 KiB
random_94.txt AC 12 ms 7180 KiB
random_95.txt AC 7 ms 6912 KiB
random_96.txt AC 7 ms 6892 KiB
sample_01.txt AC 6 ms 6832 KiB
sample_02.txt AC 6 ms 6808 KiB