답안 #835579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835579 2023-08-23T16:17:48 Z Dremix10 자동 인형 (IOI18_doll) C++17
6 / 100
73 ms 13184 KB
    #include "doll.h"
    #include <bits/stdc++.h>
    using namespace std;
    #define F first
    #define S second
    #define all(x) (x).begin(),(x).end()
    typedef long long ll;
    typedef pair<int,int> pi;
    typedef pair<ll,ll> pl;
    const int N = 3e5+5;
    const ll INF = 1e18+5;
    const int MOD = 1e9+7;
     
    vector<int> x,y,c;
    vector<vector<int> > nxt;
     
    int solve(vector<int> &a){
        assert(!a.empty());
        int n = a.size();
        int i;
     
        bool ok = 1;
        int curr = a[0];
        vector<int> p1,p2;
        
     
        for(i=0;i<n-1;i+=2){
            if(curr != a[i] || curr != a[i+1])ok = 0;
     
            p1.push_back(a[i]);
            p2.push_back(a[i+1]);
        }
        if(curr != a[n-1])ok = 0;
     
        if(ok){
            return curr;
        }
     
        if(n%2){
            /// we gotta add
            x.push_back(0);
            y.push_back(0);
            int res = x.size();
            p1.push_back(res*-1);
            p2.push_back(a.back());

            x[res-1] = solve(p1);

            y[res-1] = solve(p2);

            return res*-1;
        }
        else{

            x.push_back(solve(p1));
            y.push_back(solve(p2));
            int res = x.size();

            return res*-1;
        }
     
     
    }
     
    void create_circuit(int m, vector<int> arr) {
        int n = arr.size();
     
        c.resize(m+1);
     
        /// origin goes to first trigger
        c[0] = arr[0];
     
        int i;
        nxt.assign(m+1,vector<int>());
     
        for(i=0;i<n;i++){
            if(i < n-1)
                nxt[arr[i]].push_back(arr[i+1]);
            else
                nxt[arr[i]].push_back(0);
        }
     
        for(i=1;i<=m;i++){
            int cnt = nxt[i].size();
     
            if(cnt == 0)continue;
            else if(cnt == 1){
                c[i] = nxt[i][0];
            }
            else{
                //int idx = x.size() + 1;
     
                c[i] = solve(nxt[i]);
            }
     
        }
     
        answer(c,x,y);
     
    }
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 18 ms 6740 KB Output is correct
3 Correct 20 ms 5588 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 3796 KB Output is correct
6 Correct 23 ms 8404 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 18 ms 6740 KB Output is correct
3 Correct 20 ms 5588 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 3796 KB Output is correct
6 Correct 23 ms 8404 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 34 ms 8388 KB Output is correct
9 Correct 38 ms 9544 KB Output is correct
10 Correct 56 ms 12480 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 18 ms 6740 KB Output is correct
3 Correct 20 ms 5588 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 3796 KB Output is correct
6 Correct 23 ms 8404 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 34 ms 8388 KB Output is correct
9 Correct 38 ms 9544 KB Output is correct
10 Correct 56 ms 12480 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 260 KB Output is correct
14 Correct 73 ms 13184 KB Output is correct
15 Incorrect 38 ms 6836 KB wrong motion
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 212 KB Output is partially correct
2 Incorrect 12 ms 3788 KB wrong motion
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 212 KB Output is partially correct
2 Incorrect 12 ms 3788 KB wrong motion
3 Halted 0 ms 0 KB -