QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#394725 | #1371. Missing Number | Omar_Alaa03# | AC ✓ | 0ms | 3856kb | C++20 | 1.3kb | 2024-04-20 18:31:23 | 2024-04-20 18:31:23 |
Judging History
answer
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define no "NO"
#define yes "YES"
#define forr(n) for(int i = 0;i < n; i++)
#define d(n) cout<<"value of "<<#n<<" is "<<n<<endl
#define endl '\n'
using namespace std;
const int N = 1e6 + 5, mode = 1e9 + 7;
int transform(int idx) {
int ptr = 179;
for (int i = 9; i >= 1; i--) {
if (idx >= ptr)
return i;
ptr -= 20;
}
return 1;
}
void Code() {
int n;
string s;
cin >> n >> s;
string tmp = "";
for (int i = 1; i <= n; i++) {
tmp += to_string(i);
}
for (int i = 0; i < s.size(); i++) {
if (s[i] != tmp[i]) {
if (i > 8) {
// d(i);
// d(tmp[i]);
// d(transform(i));
if (transform(i) == tmp[i] - '0')
cout << tmp[i] << tmp[i + 1];
else
cout << tmp[i - 1] << tmp[i];
}
else
cout << tmp[i];
return;
}
}
cout << n;
}
int main() {
// fast
int tc = 1;
// cin >> tc;
while (tc--)
Code();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
2 1
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
2 2
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
100 23456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
100 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
output:
100
result:
ok single line: '100'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
100 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818384858687888990919293949596979899100
output:
82
result:
ok single line: '82'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
100 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586888990919293949596979899100
output:
87
result:
ok single line: '87'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
100 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798100
output:
99
result:
ok single line: '99'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
100 1234567891011121314151617181920212223242526272829303132333435363738394041424344454748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
output:
46
result:
ok single line: '46'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
100 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
output:
52
result:
ok single line: '52'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
20 12345678910111213141516181920
output:
17
result:
ok single line: '17'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
46 123456789101112131415161718192021222324252627282931323334353637383940414243444546
output:
30
result:
ok single line: '30'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
98 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777980818283848586878889909192939495969798
output:
78
result:
ok single line: '78'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
11 12345678911
output:
10
result:
ok single line: '10'