답안 #788548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
788548 2023-07-20T10:42:38 Z Andrey 자동 인형 (IOI18_doll) C++14
85.553 / 100
89 ms 19568 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;

vector<int> haha[200001];
vector<int> idk(500001);
int br = 1,yeah;
vector<int> x(0);
vector<int> y(0);

void dude(int a, int d) {
    x.push_back(0);
    y.push_back(0);
    int ind = br-1;
    br++;
    if(d < 0) {
        if(a == 2) {
            x[ind] = INT_MAX;
            y[ind] = INT_MAX;
        }
        else {
            x[ind] = yeah;
            y[ind] = INT_MAX;
        }
        return;
    }
    int z = (1 << (d+1));
    if(a <= z) {
        x[ind] = yeah;
        y[ind] = -br;
        dude(a,d-1);
    }
    else {
        x[ind] = -br;
        dude(a-z,d-1);
        y[ind] = -br;
        dude(z,d-1);
    }
}

void create_circuit(int m, vector<int> bruh) {
    vector<int> c(m+1);
    c[0] = bruh[0];
    int n = bruh.size();
    bruh.push_back(0);
    int a,z = 0,b,p,d = 0,e = 1;
    for(int i = 0; i < n; i++) {
        haha[bruh[i]].push_back(bruh[i+1]);
    }
    for(int i = 0; i < 200001; i++) {
        if(haha[i].empty()) {
            continue;
        }
        if(haha[i].size() == 1) {
            c[i] = haha[i][0];
        }
        else {
            c[i] = -br;
            yeah = -br;
            d = -1;
            e = 1;
            while(e*2 < haha[i].size()) {
                e*=2;
                d++;
            }
            dude(haha[i].size(),d);
            p = 0;
            for(int j = 0; j < haha[i].size(); j++) {
                d = -c[i];
                if((++idk[d-1])%2) {
                    e = x[d-1];
                }
                else {
                    e = y[d-1];
                }
                while(e != INT_MAX) {
                    d = -e;
                    if((++idk[d-1])%2) {
                        e = x[d-1];
                    }
                    else {
                        e = y[d-1];
                    }
                }
                if(idk[d-1]%2 == 1) {
                    x[d-1] = haha[i][j];
                }
                else {
                    y[d-1] = haha[i][j];
                }
            }
        }
    }
    answer(c,x,y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:62:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             while(e*2 < haha[i].size()) {
      |                   ~~~~^~~~~~~~~~~~~~~~
doll.cpp:68:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |             for(int j = 0; j < haha[i].size(); j++) {
      |                            ~~^~~~~~~~~~~~~~~~
doll.cpp:46:9: warning: unused variable 'a' [-Wunused-variable]
   46 |     int a,z = 0,b,p,d = 0,e = 1;
      |         ^
doll.cpp:46:11: warning: unused variable 'z' [-Wunused-variable]
   46 |     int a,z = 0,b,p,d = 0,e = 1;
      |           ^
doll.cpp:46:17: warning: unused variable 'b' [-Wunused-variable]
   46 |     int a,z = 0,b,p,d = 0,e = 1;
      |                 ^
doll.cpp:46:19: warning: variable 'p' set but not used [-Wunused-but-set-variable]
   46 |     int a,z = 0,b,p,d = 0,e = 1;
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6868 KB Output is correct
2 Correct 20 ms 10600 KB Output is correct
3 Correct 18 ms 10192 KB Output is correct
4 Correct 3 ms 6868 KB Output is correct
5 Correct 11 ms 8020 KB Output is correct
6 Correct 24 ms 11980 KB Output is correct
7 Correct 4 ms 6868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6868 KB Output is correct
2 Correct 20 ms 10600 KB Output is correct
3 Correct 18 ms 10192 KB Output is correct
4 Correct 3 ms 6868 KB Output is correct
5 Correct 11 ms 8020 KB Output is correct
6 Correct 24 ms 11980 KB Output is correct
7 Correct 4 ms 6868 KB Output is correct
8 Correct 34 ms 12864 KB Output is correct
9 Correct 37 ms 13032 KB Output is correct
10 Correct 51 ms 16320 KB Output is correct
11 Correct 3 ms 6868 KB Output is correct
12 Correct 3 ms 6868 KB Output is correct
13 Correct 4 ms 6868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6868 KB Output is correct
2 Correct 20 ms 10600 KB Output is correct
3 Correct 18 ms 10192 KB Output is correct
4 Correct 3 ms 6868 KB Output is correct
5 Correct 11 ms 8020 KB Output is correct
6 Correct 24 ms 11980 KB Output is correct
7 Correct 4 ms 6868 KB Output is correct
8 Correct 34 ms 12864 KB Output is correct
9 Correct 37 ms 13032 KB Output is correct
10 Correct 51 ms 16320 KB Output is correct
11 Correct 3 ms 6868 KB Output is correct
12 Correct 3 ms 6868 KB Output is correct
13 Correct 4 ms 6868 KB Output is correct
14 Correct 64 ms 18156 KB Output is correct
15 Correct 35 ms 12596 KB Output is correct
16 Correct 53 ms 16380 KB Output is correct
17 Correct 3 ms 6968 KB Output is correct
18 Correct 5 ms 6952 KB Output is correct
19 Correct 3 ms 6868 KB Output is correct
20 Correct 60 ms 17824 KB Output is correct
21 Correct 3 ms 6868 KB Output is correct
22 Correct 3 ms 6972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6868 KB Output is correct
2 Correct 3 ms 6972 KB Output is correct
3 Correct 3 ms 6868 KB Output is correct
4 Correct 4 ms 6868 KB Output is correct
5 Correct 3 ms 6972 KB Output is correct
6 Correct 4 ms 6968 KB Output is correct
7 Correct 3 ms 6868 KB Output is correct
8 Correct 3 ms 6868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6868 KB Output is correct
2 Correct 62 ms 12984 KB Output is correct
3 Correct 65 ms 13104 KB Output is correct
4 Correct 89 ms 16000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6868 KB Output is correct
2 Correct 62 ms 12984 KB Output is correct
3 Correct 65 ms 13104 KB Output is correct
4 Correct 89 ms 16000 KB Output is correct
5 Partially correct 71 ms 19460 KB Output is partially correct
6 Partially correct 68 ms 19472 KB Output is partially correct
7 Partially correct 73 ms 19568 KB Output is partially correct
8 Partially correct 69 ms 18820 KB Output is partially correct
9 Partially correct 58 ms 13460 KB Output is partially correct
10 Partially correct 75 ms 18008 KB Output is partially correct
11 Partially correct 67 ms 17068 KB Output is partially correct
12 Partially correct 39 ms 14360 KB Output is partially correct
13 Partially correct 44 ms 14548 KB Output is partially correct
14 Partially correct 46 ms 14604 KB Output is partially correct
15 Partially correct 46 ms 14860 KB Output is partially correct
16 Partially correct 5 ms 7124 KB Output is partially correct
17 Partially correct 39 ms 13140 KB Output is partially correct
18 Partially correct 40 ms 13820 KB Output is partially correct
19 Partially correct 36 ms 14088 KB Output is partially correct
20 Partially correct 56 ms 17160 KB Output is partially correct
21 Partially correct 57 ms 16984 KB Output is partially correct
22 Partially correct 53 ms 16660 KB Output is partially correct