Submission #1094652

# Submission time Handle Problem Language Result Execution time Memory
1094652 2024-09-30T08:23:18 Z irmuun Magic Show (APIO24_show) C++17
100 / 100
1 ms 1044 KB
#include <bits/stdc++.h>
#include "Alice.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

vector<pair<int,int>>Alice(){
    ll X=setN(100);
    vector<pair<int,int>>g;
    for(int i=1;i<100;i++){
        if(X%(ll)i==0){
            g.pb({i,100});
        }
        else{
            g.pb({i,X%(ll)i});
        }
    }
    return g;
}
#include <bits/stdc++.h>
#include "Bob.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

long long Bob(vector<pair<int,int>>g){
    //Chinese remainder theorom...
    ll N=100;
    vector<pair<ll,ll>>rem;
    bool even=false;
    for(auto [a,b]:g){
        if(a>b) swap(a,b);
        if(b==100){
            rem.pb({a,0});
        }
        else{
            rem.pb({b,a});
        }
    }
    vector<ll>r(101,-1);
    for(auto [a,b]:rem){
        for(ll j=1;j<=100;j++){
            if(a%j==0){
                r[j]=b%j;
            }
        }
    }
    vector<bool>prime(N+1,1);
    for(ll i=2;i<=N;i++){
        if(prime[i]){
            for(ll j=i+i;j<=N;j+=i){
                prime[j]=false;
            }
        }
    }
    vector<pair<ll,ll>>cht;
    for(ll i=2;i<=N;i++){
        if(prime[i]){
            ll cur=i,p=-1,q=-1;
            while(cur<=N){
                if(r[cur]>-1){
                    p=cur;
                    q=r[cur];
                }
                cur*=i;
            }
            if(p>0){
                cht.pb({p,q});
            }
        }
    }
    ll A=cht[0].ff,X=cht[0].ss;
    ll inf=(ll)1e18;
    for(ll i=1;i<cht.size();i++){
        for(ll c=0;c<cht[i].ff;c++){
            if((X+A*c)%cht[i].ff==cht[i].ss){
                X=X+A*c;
                break;
            }
        }
        if(inf/cht[i].ff<A){
            return X;
        }
        A*=cht[i].ff;
    }
    return X;
}

Compilation message

Bob.cpp: In function 'long long int Bob(std::vector<std::pair<int, int> >)':
Bob.cpp:61:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(ll i=1;i<cht.size();i++){
      |                ~^~~~~~~~~~~
Bob.cpp:17:10: warning: unused variable 'even' [-Wunused-variable]
   17 |     bool even=false;
      |          ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 776 KB Correct.
2 Correct 0 ms 776 KB Correct.
3 Correct 0 ms 776 KB Correct.
4 Correct 0 ms 776 KB Correct.
5 Correct 1 ms 776 KB Correct.
6 Correct 0 ms 1028 KB Correct.
7 Correct 0 ms 772 KB Correct.
8 Correct 0 ms 784 KB Correct.
9 Correct 0 ms 784 KB Correct.
10 Correct 1 ms 776 KB Correct.
11 Correct 0 ms 776 KB Correct.
12 Correct 0 ms 776 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 0 ms 776 KB Correct.
2 Correct 0 ms 776 KB Correct.
3 Correct 0 ms 776 KB Correct.
4 Correct 0 ms 776 KB Correct.
5 Correct 1 ms 776 KB Correct.
6 Correct 0 ms 1028 KB Correct.
7 Correct 0 ms 772 KB Correct.
8 Correct 0 ms 784 KB Correct.
9 Correct 0 ms 784 KB Correct.
10 Correct 1 ms 776 KB Correct.
11 Correct 0 ms 776 KB Correct.
12 Correct 0 ms 776 KB Correct.
13 Correct 1 ms 776 KB Correct.
14 Correct 0 ms 784 KB Correct.
15 Correct 0 ms 776 KB Correct.
16 Correct 1 ms 776 KB Correct.
17 Correct 0 ms 776 KB Correct.
18 Correct 0 ms 780 KB Correct.
19 Correct 0 ms 776 KB Correct.
20 Correct 0 ms 784 KB Correct.
21 Correct 0 ms 784 KB Correct.
22 Correct 0 ms 784 KB Correct.
23 Correct 0 ms 792 KB Correct.
24 Correct 0 ms 784 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 0 ms 776 KB Correct.
2 Correct 0 ms 776 KB Correct.
3 Correct 0 ms 776 KB Correct.
4 Correct 0 ms 776 KB Correct.
5 Correct 1 ms 776 KB Correct.
6 Correct 0 ms 1028 KB Correct.
7 Correct 0 ms 772 KB Correct.
8 Correct 0 ms 784 KB Correct.
9 Correct 0 ms 784 KB Correct.
10 Correct 1 ms 776 KB Correct.
11 Correct 0 ms 776 KB Correct.
12 Correct 0 ms 776 KB Correct.
13 Correct 1 ms 776 KB Correct.
14 Correct 0 ms 784 KB Correct.
15 Correct 0 ms 776 KB Correct.
16 Correct 1 ms 776 KB Correct.
17 Correct 0 ms 776 KB Correct.
18 Correct 0 ms 780 KB Correct.
19 Correct 0 ms 776 KB Correct.
20 Correct 0 ms 784 KB Correct.
21 Correct 0 ms 784 KB Correct.
22 Correct 0 ms 784 KB Correct.
23 Correct 0 ms 792 KB Correct.
24 Correct 0 ms 784 KB Correct.
25 Correct 0 ms 784 KB Correct.
26 Correct 0 ms 784 KB Correct.
27 Correct 1 ms 776 KB Correct.
28 Correct 0 ms 800 KB Correct.
29 Correct 0 ms 784 KB Correct.
30 Correct 1 ms 776 KB Correct.
31 Correct 0 ms 796 KB Correct.
32 Correct 1 ms 792 KB Correct.
33 Correct 0 ms 776 KB Correct.
34 Correct 0 ms 784 KB Correct.
35 Correct 0 ms 792 KB Correct.
36 Correct 0 ms 800 KB Correct.
37 Correct 1 ms 776 KB Correct.
38 Correct 0 ms 776 KB Correct.
39 Correct 0 ms 792 KB Correct.
40 Correct 1 ms 792 KB Correct.
41 Correct 0 ms 772 KB Correct.
42 Correct 0 ms 784 KB Correct.
43 Correct 0 ms 1044 KB Correct.
44 Correct 0 ms 780 KB Correct.