제출 #311981

#제출 시각아이디문제언어결과실행 시간메모리
311981talant117408Mechanical Doll (IOI18_doll)C++17
6 / 100
70 ms7716 KiB
#include "doll.h"
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair <ll, ll> pii;
 
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) (int)(v).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void create_circuit(int M, vector<int> A) {
    vector <int> connected(M+1), x, y;
    int i;
    vector <int> flag(M+1);
    for(auto &to : connected) to = 0;
    
    vector <pii> to(M+1, {2e9, 2e9});
    A.pb(0);
    connected[0] = A[0];
    
    for(i = 0; i < sz(A)-1; i++){
        if(to[A[i]].first == 2e9) to[A[i]].first = A[i+1];
        else to[A[i]].second = A[i+1];
    }
    
    for(i = 0; i < sz(A)-1; i++){
        if(to[A[i]].second != 2e9 && !flag[A[i]]){
            x.pb(to[A[i]].first);
            y.pb(to[A[i]].second);
            connected[A[i]] = -sz(x);
            flag[A[i]] = 1;
        }
        else if(!flag[A[i]]){
            connected[A[i]] = A[i+1];
        }
    }
    /*
    for(auto to : connected) cout << to << ' ';
    cout << endl;
    for(i = 0; i < sz(x); i++) cout << x[i] << ' ' << y[i] << endl;
    */
    answer(connected, x, y);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...