Submission #991259

# Submission time Handle Problem Language Result Execution time Memory
991259 2024-06-01T16:31:59 Z steveonalex Magic Show (APIO24_show) C++17
100 / 100
1 ms 792 KB
#include <bits/stdc++.h>
#include "Alice.h"
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
 
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll gcd(ll a, ll b){return __gcd(a, b);}
 
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}
 
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
 
template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if (a < b) {a = b; return true;}
        return false;
    }
 
template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if (a > b) {a = b; return true;}
        return false;
    }
 
template <class T>
    void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){
        for(auto item: container) out << item << separator;
        out << finish;
    }
 
template <class T>
    void remove_dup(vector<T> &a){
        sort(ALL(a));
        a.resize(unique(ALL(a)) - a.begin());
    }

ll setN(ll n){
    cerr << n << "\n";
    ll x; cin >> x;
    return x;
}

vector<pair<int, int>> Alice(){
    int n = 1000;
    ll x = setN(n);
    vector<pair<int,int>> ans;
    for(int i = 2; i<=n; ++i) {
        ans.push_back({x % (i-1) + 1, i});
    }
    return ans;
}

// int main(void){
//     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//     freopen("transfer.txt", "w", stdout);

//     vector<pair<int, int>> bru = Alice();

//     cout << bru.size() << "\n";
//     for(pair<int, int> i: bru) cout << i.first << " " << i.second << "\n";
 
//     return 0;
// }
#include <bits/stdc++.h>
#include "Bob.h"
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
 
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll gcd(ll a, ll b){return __gcd(a, b);}
 
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}
 
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
 
template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if (a < b) {a = b; return true;}
        return false;
    }
 
template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if (a > b) {a = b; return true;}
        return false;
    }
 
template <class T>
    void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){
        for(auto item: container) out << item << separator;
        out << finish;
    }
 
template <class T>
    void remove_dup(vector<T> &a){
        sort(ALL(a));
        a.resize(unique(ALL(a)) - a.begin());
    }

const ll INF = 2e18;

ll Bob(vector<pair<int, int>> E){
    int n = 1000;
    vector<int> par(n+1, -1);
    for(pair<int, int> i: E){
        if (i.first > i.second) swap(i.first, i.second);
        par[i.second] = i.first;
    }

    ll x = 0;
    ll mud = 1;

    for(int i = 3; i <= n; ++i) if (par[i] != -1){
        int r = par[i] - 1, m = i - 1;
        while(x % m != r){
            x += mud;
        }

        mud /= gcd(mud, m);
        if (INF / mud <= m){
            break;
        }
        mud *= m;
    }

    return x;
}
 
// int main(void){
//     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


//     freopen("transfer.txt", "r", stdin);

//     int m; cin >> m;
//     vector<pair<int, int>> E;
//     for(int i = 0; i<m; ++i){
//         int u, v; cin >> u >> v;
//         E.push_back({u, v});
//     }
//     cout << Bob(E) << "\n";
 
//     return 0;
// }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 780 KB Correct.
2 Correct 1 ms 784 KB Correct.
3 Correct 1 ms 780 KB Correct.
4 Correct 1 ms 780 KB Correct.
5 Correct 0 ms 788 KB Correct.
6 Correct 0 ms 780 KB Correct.
7 Correct 0 ms 788 KB Correct.
8 Correct 1 ms 784 KB Correct.
9 Correct 1 ms 780 KB Correct.
10 Correct 1 ms 780 KB Correct.
11 Correct 1 ms 780 KB Correct.
12 Correct 0 ms 792 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 780 KB Correct.
2 Correct 1 ms 784 KB Correct.
3 Correct 1 ms 780 KB Correct.
4 Correct 1 ms 780 KB Correct.
5 Correct 0 ms 788 KB Correct.
6 Correct 0 ms 780 KB Correct.
7 Correct 0 ms 788 KB Correct.
8 Correct 1 ms 784 KB Correct.
9 Correct 1 ms 780 KB Correct.
10 Correct 1 ms 780 KB Correct.
11 Correct 1 ms 780 KB Correct.
12 Correct 0 ms 792 KB Correct.
13 Correct 0 ms 780 KB Correct.
14 Correct 0 ms 780 KB Correct.
15 Correct 1 ms 780 KB Correct.
16 Correct 0 ms 780 KB Correct.
17 Correct 1 ms 788 KB Correct.
18 Correct 1 ms 792 KB Correct.
19 Correct 1 ms 780 KB Correct.
20 Correct 0 ms 788 KB Correct.
21 Correct 1 ms 780 KB Correct.
22 Correct 1 ms 788 KB Correct.
23 Correct 1 ms 780 KB Correct.
24 Correct 1 ms 780 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 780 KB Correct.
2 Correct 1 ms 784 KB Correct.
3 Correct 1 ms 780 KB Correct.
4 Correct 1 ms 780 KB Correct.
5 Correct 0 ms 788 KB Correct.
6 Correct 0 ms 780 KB Correct.
7 Correct 0 ms 788 KB Correct.
8 Correct 1 ms 784 KB Correct.
9 Correct 1 ms 780 KB Correct.
10 Correct 1 ms 780 KB Correct.
11 Correct 1 ms 780 KB Correct.
12 Correct 0 ms 792 KB Correct.
13 Correct 0 ms 780 KB Correct.
14 Correct 0 ms 780 KB Correct.
15 Correct 1 ms 780 KB Correct.
16 Correct 0 ms 780 KB Correct.
17 Correct 1 ms 788 KB Correct.
18 Correct 1 ms 792 KB Correct.
19 Correct 1 ms 780 KB Correct.
20 Correct 0 ms 788 KB Correct.
21 Correct 1 ms 780 KB Correct.
22 Correct 1 ms 788 KB Correct.
23 Correct 1 ms 780 KB Correct.
24 Correct 1 ms 780 KB Correct.
25 Correct 1 ms 780 KB Correct.
26 Correct 1 ms 780 KB Correct.
27 Correct 0 ms 780 KB Correct.
28 Correct 0 ms 780 KB Correct.
29 Correct 0 ms 780 KB Correct.
30 Correct 0 ms 780 KB Correct.
31 Correct 1 ms 780 KB Correct.
32 Correct 1 ms 780 KB Correct.
33 Correct 0 ms 780 KB Correct.
34 Correct 1 ms 776 KB Correct.
35 Correct 1 ms 780 KB Correct.
36 Correct 1 ms 780 KB Correct.
37 Correct 1 ms 780 KB Correct.
38 Correct 0 ms 784 KB Correct.
39 Correct 1 ms 780 KB Correct.
40 Correct 0 ms 780 KB Correct.
41 Correct 1 ms 780 KB Correct.
42 Correct 1 ms 784 KB Correct.
43 Correct 1 ms 780 KB Correct.
44 Correct 1 ms 792 KB Correct.