Task: | Alkuluvut |
Sender: | ArktinenKarpalo |
Submission time: | 2025-09-27 10:48:51 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.40 s | 1, 2, 3 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <bits/stdc++.h> typedef long long ll; using namespace std; bool isPrime(ll a) { for (ll i = 2; i * i <= a; i++) { if (a % i == 0) return false; } return true; } bool isOk(string s) { if (s[0] == '0') return false; return isPrime(atoll(s.c_str())); } string solve(string luvut) { int tries = 100000; while (tries--) { string luku; for (auto u : luvut) luku.push_back(u); int lol = max(0, max(2, rand() % 16) - (int)luku.size()); for (int i = 0; i < lol; i++) { luku.push_back(luvut[rand() % luvut.size()]); } random_shuffle(luku.begin(), luku.end()); if (isPrime(atoll(luku.c_str()))) { return "YES\n"+luku; } } return "NO"; } int main() { int t; cin >> t; while (t--) { int k; cin >> k; string luvut(k, '0'); for (int i = 0; i < k; i++) cin >> luvut[i]; cout << solve(luvut) << "\n"; } }
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
10 1 0 1 1 ... |
correct output |
---|
NO YES 11 YES 2 ... |
user output |
---|
YES 0000000 YES 11 NO ... |
Test 2
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
175 1 0 1 1 ... |
correct output |
---|
NO YES 11 YES 2 ... |
user output |
---|
(empty) |
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) |