QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#591822 | #8726. Magic Show | isirazeev | 0 | 0ms | 1864kb | C++20 | 1.7kb | 2024-09-26 18:09:21 | 2024-09-26 18:09:22 |
Alice
#include <vector>
#include "Alice.h"
#include <algorithm>
#include <random>
#include <climits>
using namespace std;
std::vector<std::pair<int,int>> Alice(){
long long x = setN(5000);
vector<pair<int, int>> edges;
for(int i = 1; i <= 4999; i++)
edges.emplace_back(x % i + 1, i + 1);
return edges;
}
Bob
#include <vector>
#include "Bob.h"
#include <iostream>
using namespace std;
pair<pair<long long, long long>, long long> ext_gcd(int a, int b){
if(a < b) swap(a, b);
if(b == 0) return {{1, 0}, a};
auto p = ext_gcd(b, a % b);
return make_pair(make_pair(p.first.second, p.first.first - (a / b) * p.first.second), p.second);
}
long long find(pair<long long, long long> a, pair<long long, long long> q){
int a1 = a.second, a2 = q.second, r1 = a.first, r2 = q.first;
auto p = ext_gcd(a1, a2);
return a1 * p.first.first * (r2 - r1) + r1;
}
long long solve(vector<pair<int, int>> v){
while((int)v.size() > 2){
auto p = v[v.size() - 2], q = v[v.size() - 1];
v.pop_back(), v.pop_back();
long long x = find(p, q);
v.emplace_back(x, p.second * q.second);
}
return find(v[0], v[1]);
}
long long Bob(std::vector<std::pair<int,int>> V){
vector<pair<int, int>> edges;
for(int i = 1; i < V.size() && edges.size() < 5; i++)
edges.emplace_back(V[i].first - 1, V[i].second - 1);
long long res = solve(edges);
for(long long x = res; x <= (int)1e18; x += res){
bool F = false;
for(int i = 1; i < V.size(); i++){
if(x % (V[i].second - 1) != (V[i].first - 1)){
F = true;
break;
}
}
if(!F) return x;
}
return -1;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
1 4005
output:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 2 5 1 6 4 7 2 8 6 9 1 10 6 11 2 12 10 13 2 14 2 15 1 16 6 17 11 18 10 19 16 20 6 21 16 22 2 23 4 24 22 25 6 26 2 27 10 28 2 29 4 30 16 31 7 32 6 33 13 3...
input:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 2 5 1 6 4 7 2 8 6 9 1 10 6 11 2 12 10 13 2 14 2 15 1 16 6 17 11 18 10 19 16 20 6 21 16 22 2 23 4 24 22 25 6 26 2 27 10 28 2 29 4 30 16 31 7 32 6 33 13 3...
output:
2 5000 2648 1 6 1 46 1 90 1 446 1 802 2 3 2 5 2 23 2 29 2 45 2 92 2 144 2 155 2 183 2 573 2 2003 3 4004 4 7 4 24 4 30 4 59 4 139 4 1335 4 2002 4 4003 5 4002 6 11 6 17 6 26 6 33 6 126 6 161 6 501 6 1001 6 2001 7 44 7 130 7 4000 9 572 9 3998 10 13 10 19 10 28 10 55 10 109 10 112 10 445 10 667 10 1000 ...
input:
2 5000 2648 1 6 1 46 1 90 1 446 1 802 2 3 2 5 2 23 2 29 2 45 2 92 2 144 2 155 2 183 2 573 2 2003 3 4004 4 7 4 24 4 30 4 59 4 139 4 1335 4 2002 4 4003 5 4002 6 11 6 17 6 26 6 33 6 126 6 161 6 501 6 1001 6 2001 7 44 7 130 7 4000 9 572 9 3998 10 13 10 19 10 28 10 55 10 109 10 112 10 445 10 667 10 1000 ...
output:
Subtask #2:
score: 0
Time Limit Exceeded
Test #13:
score: 0
Time Limit Exceeded
input:
1 17476204
output:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 1 3 2 4 1 5 5 6 5 7 5 8 5 9 5 10 5 11 10 12 5 13 6 14 5 15 5 16 13 17 1 18 5 19 5 20 5 21 5 22 21 23 23 24 5 25 5 26 19 27 23 28 5 29 22 30 5 31 17 32 13 33 32 ...
input:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 1 3 2 4 1 5 5 6 5 7 5 8 5 9 5 10 5 11 10 12 5 13 6 14 5 15 5 16 13 17 1 18 5 19 5 20 5 21 5 22 21 23 23 24 5 25 5 26 19 27 23 28 5 29 22 30 5 31 17 32 13 33 32 ...
output:
2 5000 4101 1 2 1 5 1 18 1 35 1 69 2 4 2 108 2 322 4 1188 5 6 5 7 5 8 5 9 5 10 5 11 5 13 5 16 5 19 5 21 5 22 5 26 5 29 5 31 5 37 5 39 5 43 5 46 5 51 5 58 5 61 5 64 5 74 5 76 5 77 5 85 5 96 5 101 5 106 5 115 5 121 5 127 5 134 5 147 5 151 5 153 5 172 5 176 5 181 5 201 5 220 5 226 5 267 5 281 5 286 5 2...
input:
2 5000 4101 1 2 1 5 1 18 1 35 1 69 2 4 2 108 2 322 4 1188 5 6 5 7 5 8 5 9 5 10 5 11 5 13 5 16 5 19 5 21 5 22 5 26 5 29 5 31 5 37 5 39 5 43 5 46 5 51 5 58 5 61 5 64 5 74 5 76 5 77 5 85 5 96 5 101 5 106 5 115 5 121 5 127 5 134 5 147 5 151 5 153 5 172 5 176 5 181 5 201 5 220 5 226 5 267 5 281 5 286 5 2...
output:
Subtask #3:
score: 0
Wrong Answer
Test #25:
score: 0
Wrong Answer
time: 0ms = 0ms + 0ms
memory: 1864kb,1808kb
input:
1 355365355024496523
output:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 4 5 4 6 4 7 1 8 4 9 4 10 4 11 4 12 4 13 6 14 8 15 4 16 12 17 15 18 4 19 19 20 4 21 1 22 4 23 10 24 4 25 24 26 6 27 13 28 8 29 11 30 4 31 7 32 12 33 4 34...
input:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 4 5 4 6 4 7 1 8 4 9 4 10 4 11 4 12 4 13 6 14 8 15 4 16 12 17 15 18 4 19 19 20 4 21 1 22 4 23 10 24 4 25 24 26 6 27 13 28 8 29 11 30 4 31 7 32 12 33 4 34...
output:
2 5000 3015 1 2 1 4 1 380 2 3 4 5 4 6 4 9 4 11 4 25 4 31 4 34 4 41 4 45 4 56 4 61 4 67 4 73 4 89 4 91 4 100 4 121 4 133 4 166 4 181 4 199 4 221 4 284 4 331 4 361 4 397 4 496 4 567 4 793 4 991 4 1321 4 1416 4 1699 4 2265 4 2831 4 3114 4 3397 4 4246 6 14 6 27 6 107 6 690 10 24 10 47 10 112 10 167 10 2...
input:
2 5000 3015 1 2 1 4 1 380 2 3 4 5 4 6 4 9 4 11 4 25 4 31 4 34 4 41 4 45 4 56 4 61 4 67 4 73 4 89 4 91 4 100 4 121 4 133 4 166 4 181 4 199 4 221 4 284 4 331 4 361 4 397 4 496 4 567 4 793 4 991 4 1321 4 1416 4 1699 4 2265 4 2831 4 3114 4 3397 4 4246 6 14 6 27 6 107 6 690 10 24 10 47 10 112 10 167 10 2...
output:
9ff923928e5675d6f7ae686fcfb20beac84bc7b1a47cf13bde24b59497bcae3b4900097049e1c568aa409defdbadf4cfc599c0e496e22068170cce547295ffa4 Incorrect answer.