Submission #823375

# Submission time Handle Problem Language Result Execution time Memory
823375 2023-08-12T12:37:34 Z Trumling Mechanical Doll (IOI18_doll) C++14
6 / 100
68 ms 11688 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;
            }

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

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

            X.pb(-(start+1));
            Y.pb(-(start+1));
            q.push({{d,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)
      |                    ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 21 ms 6708 KB Output is correct
3 Correct 15 ms 5328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 8 ms 4180 KB Output is correct
6 Correct 35 ms 8112 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 21 ms 6708 KB Output is correct
3 Correct 15 ms 5328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 8 ms 4180 KB Output is correct
6 Correct 35 ms 8112 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 35 ms 7572 KB Output is correct
9 Correct 36 ms 9040 KB Output is correct
10 Correct 62 ms 11688 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 21 ms 6708 KB Output is correct
3 Correct 15 ms 5328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 8 ms 4180 KB Output is correct
6 Correct 35 ms 8112 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 35 ms 7572 KB Output is correct
9 Correct 36 ms 9040 KB Output is correct
10 Correct 62 ms 11688 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 68 ms 11224 KB wrong motion
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -