제출 #1354311

#제출 시각아이디문제언어결과실행 시간메모리
1354311TroySer마술쇼 (APIO24_show)C++20
35 / 100
4 ms580 KiB
#include <bits/stdc++.h>
#include <vector>
#include "Alice.h"

using namespace std;
using ll = long long;

vector<pair<int,int> > Alice() {
    
    ll X = setN(1000);

    vector<pair<int, int> > treeEdges;
    treeEdges.reserve(1000 - 1);
    
    // always connect to previous index, which is GUARANTEED to be connected
    // by induction; moreover N - 1 edges w/ N vertices guarantees tree
    for (ll mod = 2; mod <= 1000; mod++) {
        // at most [1, mod - 1]
        treeEdges.push_back({(X % (mod - 1)) + 1, mod});
    }

    return treeEdges;

}
#include <bits/stdc++.h>
#include <vector>
#include "Bob.h"

using namespace std;
using ll = long long;

const ll MAX_CAP = 9e18;

ll Bob(vector<pair<int, int> > V) {

    // totalX (mod totalM)
    ll totalX = 0, totalM = 1;
    
    for (auto &congruence: V) {

        // it is in form r (mod m)
        auto [r, m] = congruence;
        // r: [0, mod - 2], which is of class (mod m - 1)
        if (r > m) swap(r, m);
        r--; m--;
        
        while (totalX % m != r) {
            totalX += totalM;
        }

        totalM = lcm(totalM, m);
        totalX %= totalM;

        if (totalX > MAX_CAP) break;

    }

    return totalX;

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...