Submission #1094652

#TimeUsernameProblemLanguageResultExecution timeMemory
1094652irmuunMagic Show (APIO24_show)C++17
100 / 100
1 ms1044 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...