QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#59672 | #1371. Missing Number | abdelrahman001# | WA | 2ms | 3568kb | C++20 | 956b | 2022-10-31 18:48:27 | 2022-10-31 18:48:29 |
Judging History
answer
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1e5 + 5;
int n, cnt[10], f[10];
string s;
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> s;
for(int i = 1;i <= n;i++) {
string cur = to_string(i);
for(auto j : cur)
cnt[j - '0']++;
}
for(auto i : s)
f[i - '0']++;
vector<int> v;
for(int i = 0;i <= 9;i++) {
if(f[i] != cnt[i])
v.push_back(i);
}
if(v.size() == 1) {
if(cnt[v[0]] - f[v[0]] != 1)
cout << v[0];
return cout << v[0], 0;
}
if(v[0] == 0) {
cout << v[1];
if(cnt[0] - f[0] != 1)
cout << "0";
cout << "0";
return 0;
}
if(cnt[v[0]] - f[v[0]] < cnt[v[1]] - f[v[1]])
swap(v[0], v[1]);
cout << v[0] << v[1];
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3492kb
input:
2 1
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
2 2
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3532kb
input:
100 23456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
100 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
output:
100
result:
ok single line: '100'
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 3568kb
input:
100 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818384858687888990919293949596979899100
output:
28
result:
wrong answer 1st lines differ - expected: '82', found: '28'