QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#718368 | #3322. Array of Discord | qwerasdf | WA | 0ms | 3612kb | C++20 | 2.0kb | 2024-11-06 20:21:23 | 2024-11-06 20:21:23 |
Judging History
answer
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder; //https://github.com/atcoder/ac-library
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define bit(n, k) ((n >> k) & 1)
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> pii;
bool check(ll x, ll y){
string s=to_string(x), t=to_string(y);
if((int)s.length()!=(int)t.length()){
return false;
}
else{
int n=(int)s.length();
if(n==1){
if(y==9){
if(x==0)return false;
return true;
}
else{
return true;
}
}
if(s[0]==t[0]){
}
if(s[0]!='1')return true;
// s[0]=='1'
if(t[0]!='9')return true;
s[0]=t[0];
return stoll(s)>stoll(t);
}
}
void test_case(int tt){
int n; cin>>n;
int ok=-1;
vector<ll> a(n);
rep(i,0,n)cin>>a[i];
rep(i,0,n-1){
if(check(a[i],a[i+1])){
ok=i;
break;
}
}
if(ok==-1){
cout<<"impossible\n";
return;
}
ll x=a[ok], y=a[ok+1];
string s=to_string(x), t=to_string(y);
int m=(int)s.length();
if(m==1){
if(x==0)a[ok]=9;
else a[ok+1]=0;
}
else{
if(s[0]==t[0]){
if(s[0]!='9')s[0]='9';
else t[0]='1';
}
else{
if(s[0]!='1'){
t[0]='1';
}
else if(t[0]!='9'){
s[0]='9';
}
else{
s[0]=t[0];
}
}
a[ok]=stoll(s);
a[ok+1]=stoll(t);
}
rep(i,0,n)cout<<a[i]<<' ';
return;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin>>t;
rep(i, 1, t + 1)
{
test_case(i);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
input:
10 0 1 2 3 4 5 6 7 8 9
output:
9 1 2 3 4 5 6 7 8 9
result:
ok single line: '9 1 2 3 4 5 6 7 8 9 '
Test #2:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
2 0 0
output:
9 0
result:
ok single line: '9 0 '
Test #3:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
2 0 1
output:
9 1
result:
ok single line: '9 1 '
Test #4:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
2 0 9
output:
impossible
result:
ok single line: 'impossible'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
2 1 9
output:
1 0
result:
ok single line: '1 0 '
Test #6:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
2 9 9
output:
9 0
result:
ok single line: '9 0 '
Test #7:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
3 0 0 9
output:
9 0 9
result:
ok single line: '9 0 9 '
Test #8:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
3 0 1 9
output:
9 1 9
result:
ok single line: '9 1 9 '
Test #9:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
3 0 9 9
output:
0 9 0
result:
ok single line: '0 9 0 '
Test #10:
score: -100
Wrong Answer
time: 0ms
memory: 3524kb
input:
3 1 1 9
output:
1 0 9
result:
wrong answer 1st lines differ - expected: '9 1 9', found: '1 0 9 '