QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#821519#9063. Champernowne VerificationWeaRD276#AC ✓1ms3828kbC++201.1kb2024-12-19 16:24:332024-12-19 16:24:39

Judging History

This is the latest submission verdict.

  • [2024-12-19 16:24:39]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 3828kb
  • [2024-12-19 16:24:33]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;


int solve()
{
	int n;
	if (!(cin >> n))
		return 1;
	
	string s = to_string(n);
	n = sz(s);
	bool ok = 1;
	int nm = 0;
	FOR (i, 0, n)
		ok &= s[i] == i + '1';
	
	if (ok)
		cout << s.back() << '\n';
	else
		cout << "-1\n";
	
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int TET = 1e9;
	//cin >> TET;
	for (int i = 1; i <= TET; i++)
	{
		if (solve())
		{
			break;
		}
		#ifdef ONPC
			cerr << "_____________________________\n";
		#endif
	}
	#ifdef ONPC
		cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
	#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3540kb

input:

123456789

output:

9

result:

ok single line: '9'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

1000000000

output:

-1

result:

ok single line: '-1'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

11

output:

-1

result:

ok single line: '-1'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3480kb

input:

1324

output:

-1

result:

ok single line: '-1'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

41

output:

-1

result:

ok single line: '-1'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3748kb

input:

72841877

output:

-1

result:

ok single line: '-1'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

8258

output:

-1

result:

ok single line: '-1'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

12345

output:

5

result:

ok single line: '5'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

204

output:

-1

result:

ok single line: '-1'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

76254

output:

-1

result:

ok single line: '-1'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

444

output:

-1

result:

ok single line: '-1'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

34567490

output:

-1

result:

ok single line: '-1'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

30246

output:

-1

result:

ok single line: '-1'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

52

output:

-1

result:

ok single line: '-1'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

768582

output:

-1

result:

ok single line: '-1'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

72200

output:

-1

result:

ok single line: '-1'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

24729349

output:

-1

result:

ok single line: '-1'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

123465789

output:

-1

result:

ok single line: '-1'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

58912

output:

-1

result:

ok single line: '-1'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

51494

output:

-1

result:

ok single line: '-1'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

123546

output:

-1

result:

ok single line: '-1'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

4527800

output:

-1

result:

ok single line: '-1'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

12345678

output:

8

result:

ok single line: '8'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

2612

output:

-1

result:

ok single line: '-1'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

17

output:

-1

result:

ok single line: '-1'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

1324567

output:

-1

result:

ok single line: '-1'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

8020

output:

-1

result:

ok single line: '-1'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

56

output:

-1

result:

ok single line: '-1'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

124026951

output:

-1

result:

ok single line: '-1'

Test #30:

score: 0
Accepted
time: 0ms
memory: 3480kb

input:

292386603

output:

-1

result:

ok single line: '-1'

Test #31:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

53

output:

-1

result:

ok single line: '-1'

Test #32:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

588

output:

-1

result:

ok single line: '-1'

Test #33:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

5636619

output:

-1

result:

ok single line: '-1'

Test #34:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

87387385

output:

-1

result:

ok single line: '-1'

Test #35:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

647403

output:

-1

result:

ok single line: '-1'

Test #36:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

2124484

output:

-1

result:

ok single line: '-1'

Test #37:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

878876

output:

-1

result:

ok single line: '-1'

Test #38:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

2713

output:

-1

result:

ok single line: '-1'

Test #39:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

225066

output:

-1

result:

ok single line: '-1'

Test #40:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

16

output:

-1

result:

ok single line: '-1'

Test #41:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

8861341

output:

-1

result:

ok single line: '-1'

Test #42:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

465301583

output:

-1

result:

ok single line: '-1'

Test #43:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

28821160

output:

-1

result:

ok single line: '-1'

Test #44:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

38227370

output:

-1

result:

ok single line: '-1'

Test #45:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

6407522

output:

-1

result:

ok single line: '-1'

Test #46:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

59771

output:

-1

result:

ok single line: '-1'

Test #47:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

172

output:

-1

result:

ok single line: '-1'

Test #48:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

6384

output:

-1

result:

ok single line: '-1'

Test #49:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

123456

output:

6

result:

ok single line: '6'

Test #50:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

938

output:

-1

result:

ok single line: '-1'

Test #51:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

19

output:

-1

result:

ok single line: '-1'

Test #52:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

68

output:

-1

result:

ok single line: '-1'

Test #53:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

162149411

output:

-1

result:

ok single line: '-1'

Test #54:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

44616

output:

-1

result:

ok single line: '-1'

Test #55:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

699317

output:

-1

result:

ok single line: '-1'

Test #56:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

508621

output:

-1

result:

ok single line: '-1'

Test #57:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

474249229

output:

-1

result:

ok single line: '-1'

Test #58:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

765922

output:

-1

result:

ok single line: '-1'

Test #59:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

270066653

output:

-1

result:

ok single line: '-1'

Test #60:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

1234567

output:

7

result:

ok single line: '7'

Test #61:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

123

output:

3

result:

ok single line: '3'

Test #62:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

12346578

output:

-1

result:

ok single line: '-1'

Test #63:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

756537

output:

-1

result:

ok single line: '-1'

Test #64:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

1234

output:

4

result:

ok single line: '4'

Test #65:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

767

output:

-1

result:

ok single line: '-1'

Test #66:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

56488

output:

-1

result:

ok single line: '-1'

Test #67:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

818

output:

-1

result:

ok single line: '-1'

Test #68:

score: 0
Accepted
time: 0ms
memory: 3460kb

input:

11395519

output:

-1

result:

ok single line: '-1'

Test #69:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

770111437

output:

-1

result:

ok single line: '-1'

Test #70:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

283702

output:

-1

result:

ok single line: '-1'

Test #71:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

9111

output:

-1

result:

ok single line: '-1'

Test #72:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

1

output:

1

result:

ok single line: '1'

Test #73:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

652579

output:

-1

result:

ok single line: '-1'

Test #74:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

866

output:

-1

result:

ok single line: '-1'

Test #75:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

7422

output:

-1

result:

ok single line: '-1'

Test #76:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

41901

output:

-1

result:

ok single line: '-1'

Test #77:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

98421265

output:

-1

result:

ok single line: '-1'

Test #78:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

12

output:

2

result:

ok single line: '2'

Test #79:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

8294546

output:

-1

result:

ok single line: '-1'

Test #80:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

564964198

output:

-1

result:

ok single line: '-1'

Test #81:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

5307

output:

-1

result:

ok single line: '-1'

Test #82:

score: 0
Accepted
time: 0ms
memory: 3480kb

input:

89

output:

-1

result:

ok single line: '-1'

Test #83:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

9790501

output:

-1

result:

ok single line: '-1'

Test #84:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

4094

output:

-1

result:

ok single line: '-1'

Test #85:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

183

output:

-1

result:

ok single line: '-1'

Test #86:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

46295692

output:

-1

result:

ok single line: '-1'

Test #87:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

62748918

output:

-1

result:

ok single line: '-1'

Test #88:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

13245

output:

-1

result:

ok single line: '-1'

Test #89:

score: 0
Accepted
time: 0ms
memory: 3476kb

input:

8101

output:

-1

result:

ok single line: '-1'

Test #90:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

4704081

output:

-1

result:

ok single line: '-1'

Test #91:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

370623466

output:

-1

result:

ok single line: '-1'

Test #92:

score: 0
Accepted
time: 0ms
memory: 3476kb

input:

367719186

output:

-1

result:

ok single line: '-1'

Test #93:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

6998274

output:

-1

result:

ok single line: '-1'

Test #94:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

85123

output:

-1

result:

ok single line: '-1'

Test #95:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

8956409

output:

-1

result:

ok single line: '-1'

Test #96:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

86

output:

-1

result:

ok single line: '-1'