Task: | Alkuluvut |
Sender: | jubidubi |
Submission time: | 2025-09-28 21:18:35 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 17 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 17 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#2 | WRONG ANSWER | 0.65 s | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Compiler report
input/code.cpp: In function 'll make_num(std::vector<long long int>&, ll, ll, int)': input/code.cpp:16:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 16 | for (ll i = 0; i < v.size(); ++i) { | ~~^~~~~~~~~~
Code
#include <bits/stdc++.h> using namespace std; using ll = long long; bool is_prime(ll x) { if (x == 0) return false; for (ll c = 2; c * c <= x; ++c) { if (x % c == 0) return false; } return true; } ll make_num(vector<ll> &v, ll xi, ll xv, int count) { ll x = 0; ll pwr = 1; for (ll i = 0; i < v.size(); ++i) { x += pwr * v[i]; pwr *= 10; if (i == xi) { while (count--) { x += pwr * xv; pwr *= 10; } } } return x; } void solve() { int n; cin >> n; vector<ll> v(n); for (int i = 0; i < n; ++i) cin >> v[i]; if (n == 1) { if (v[0] == 1) { cout << "YES" << endl; cout << 11 << endl; return; } if (is_prime(v[0])) { cout << "YES" << endl; cout << v[0] << endl; } else { cout << "NO" << endl; } return; } if (n == 2 && (v[0] == 0 || v[1] == 0)) { cout << "NO" << endl; return; } set<int> s; for (int x : v) s.insert(x); int l = -1; if (s.count(1)) l = 1; else if (s.count(7)) l = 7; else if (s.count(3)) l = 3; else if (s.count(9)) l = 9; if (l == -1) { cout << "NO" << endl; return; } v.push_back(l); reverse(v.begin(), v.end()); v.push_back(l); for (int i = 0; i < n; ++i) { for (int x : v) { for (int count = 1; count < 13 - n; ++count) { ll num = make_num(v, i, x, count); if (is_prime(num)) { cout << "YES" << endl; cout << num << endl; return; } } } } cout << "NO" << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int ttt; cin >> ttt; while (ttt--) solve(); }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
10 1 0 1 1 ... |
correct output |
---|
NO YES 11 YES 2 ... |
user output |
---|
NO YES 11 YES 2 ... |
Test 2
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
175 1 0 1 1 ... |
correct output |
---|
NO YES 11 YES 2 ... |
user output |
---|
NO YES 11 YES 2 ... |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
848 4 0 1 2 3 4 0 1 2 4 ... |
correct output |
---|
YES 10223 YES 4021 YES ... |
user output |
---|
(empty) |