QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#343748 | #8254. Water Journal | EsraaSyam# | AC ✓ | 0ms | 3724kb | C++20 | 1.3kb | 2024-03-03 00:08:44 | 2024-03-03 00:08:44 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define nl "\n"
#define ll long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int) v.size()
template<typename T = int>
istream &operator>>(istream &in, vector<T> &v) {
for (auto &x: v) in >> x;
return in;
}
template<typename T = int>
ostream &operator<<(ostream &out, const vector<T> &v) {
for (const T &x: v) out << x << " ";
return out;
}
void Sira() {
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}
void solve(){
int n , a , b;
cin >> n >> a >> b;
bool ok_a = false , ok_b = false;
for(int i = 0 ; i < n - 1 ; i++){
int x;
cin >> x;
if(x == a) ok_a = true;
if(x == b) ok_b = true;
}
if(ok_a and ok_b){
for(int i = a ; i <= b ; i++){
cout << i << nl;
}
}else if(!ok_a and !ok_b){
cout << -1 << nl;
}else{
if(!ok_a){
cout << a << nl;
}else{
cout << b << nl;
}
}
}
int main() {
Sira();
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
input:
5 1 5 2 2 4 4
output:
-1
result:
ok single line: '-1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
5 1 5 1 2 4 5
output:
1 2 3 4 5
result:
ok 5 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
5 1 5 1 2 3 4
output:
5
result:
ok single line: '5'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 1 5 2 4 5 1
output:
1 2 3 4 5
result:
ok 5 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
5 1 5 3 4 2 1
output:
5
result:
ok single line: '5'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
8 12 12 12 12 12 12 12 12 12
output:
12
result:
ok single line: '12'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
2 1 50 24
output:
-1
result:
ok single line: '-1'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
2 2 49 49
output:
2
result:
ok single line: '2'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
2 2 49 2
output:
49
result:
ok single line: '49'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
6 1 45 10 15 20 25 40
output:
-1
result:
ok single line: '-1'