답안 #823384

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823384 2023-08-12T12:47:25 Z Trumling 자동 인형 (IOI18_doll) C++14
53 / 100
82 ms 15412 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;
#define INF 99999999999999
#define pb  push_back

void create_circuit(int M, std::vector<int> A) {
  int N = A.size();
  A.pb(0);

  vector<int> C(M + 1);
  vector<vector<int>>vis(M+1);
  vector<int>sw(M+1,0);
  ll idx=0;

  vector<int> X, Y;
  C[0]=A[0];
  for(int i=0;i<N;i++)
    vis[A[i]].pb(i);
  
  for(int i=1;i<=M;i++)
    {   
        if(!vis[i].size())
            continue;
        if(vis[i].size()==1)
        {
            C[i]=A[vis[i][0]+1];
            continue;
        }
        ll j=0;
        while((1<<j)<vis[i].size())
            j++;

        ll start=idx;
        C[i]=-(idx+1);
        X.pb(-(idx+1));
        Y.pb(-(idx+1));
        
        queue<pair<pair<int,int>,pair<int,int>>>q;
        q.push({{1,idx},{0,1}});
        idx++;

        while(!q.empty())
        {
            ll d=q.front().F.F,id=q.front().F.S;
            ll l=q.front().S.F,r=q.front().S.S;
            q.pop();

            if(j==d)
            {
                if(l<vis[i].size()-1);
                    X[id]=A[vis[i][l]+1];
                if(r<vis[i].size()-1)
                    Y[id]=A[vis[i][r]+1];
                if(r==(1<<j)-1)
                    Y[id]=A[vis[i][vis[i].size()-1]+1];
                continue;
            }

            
            X[id]=-(idx+1);
            Y[id]=-(idx+2);

            X.pb(-(start+1));
            Y.pb(-(start+1));
            q.push({{d+1,idx},{l,l+(1<<d)}});
            
            idx++;

            X.pb(-(start+1));
            Y.pb(-(start+1));
            q.push({{d+1,idx},{r,r+(1<<d)}});
            idx++;
        }
    }
    /*
    for(int i=0;i<=M;i++)
    cout<<C[i]<<' ';
    cout<<'\n';

    for(int i=0;i<X.size();i++)
    cout<<X[i]<<' '<<Y[i]<<'\n';*/
  answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:35:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         while((1<<j)<vis[i].size())
      |               ~~~~~~^~~~~~~~~~~~~~
doll.cpp:55:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |                 if(l<vis[i].size()-1);
      |                    ~^~~~~~~~~~~~~~~~
doll.cpp:55:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   55 |                 if(l<vis[i].size()-1);
      |                 ^~
doll.cpp:56:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   56 |                     X[id]=A[vis[i][l]+1];
      |                     ^
doll.cpp:57:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |                 if(r<vis[i].size()-1)
      |                    ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 20 ms 6696 KB Output is correct
3 Correct 16 ms 5328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 10 ms 4180 KB Output is correct
6 Correct 27 ms 8112 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 20 ms 6696 KB Output is correct
3 Correct 16 ms 5328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 10 ms 4180 KB Output is correct
6 Correct 27 ms 8112 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 35 ms 7504 KB Output is correct
9 Correct 39 ms 8968 KB Output is correct
10 Correct 55 ms 11708 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 20 ms 6696 KB Output is correct
3 Correct 16 ms 5328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 10 ms 4180 KB Output is correct
6 Correct 27 ms 8112 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 35 ms 7504 KB Output is correct
9 Correct 39 ms 8968 KB Output is correct
10 Correct 55 ms 11708 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 65 ms 11164 KB Output is correct
15 Correct 48 ms 6288 KB Output is correct
16 Correct 53 ms 8900 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 62 ms 10940 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Correct 30 ms 7092 KB Output is correct
3 Partially correct 50 ms 10068 KB Output is partially correct
4 Partially correct 55 ms 11352 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Correct 30 ms 7092 KB Output is correct
3 Partially correct 50 ms 10068 KB Output is partially correct
4 Partially correct 55 ms 11352 KB Output is partially correct
5 Partially correct 76 ms 13620 KB Output is partially correct
6 Partially correct 82 ms 14228 KB Output is partially correct
7 Partially correct 79 ms 14076 KB Output is partially correct
8 Partially correct 81 ms 14356 KB Output is partially correct
9 Partially correct 51 ms 10148 KB Output is partially correct
10 Partially correct 81 ms 15412 KB Output is partially correct
11 Partially correct 79 ms 14656 KB Output is partially correct
12 Partially correct 51 ms 10180 KB Output is partially correct
13 Partially correct 52 ms 9328 KB Output is partially correct
14 Partially correct 51 ms 9212 KB Output is partially correct
15 Partially correct 49 ms 9044 KB Output is partially correct
16 Partially correct 2 ms 596 KB Output is partially correct
17 Partially correct 42 ms 8040 KB Output is partially correct
18 Partially correct 42 ms 8064 KB Output is partially correct
19 Partially correct 45 ms 9212 KB Output is partially correct
20 Partially correct 63 ms 11428 KB Output is partially correct
21 Partially correct 70 ms 13240 KB Output is partially correct
22 Partially correct 55 ms 10788 KB Output is partially correct