Submission #823819

# Submission time Handle Problem Language Result Execution time Memory
823819 2023-08-13T07:34:06 Z Trumling Mechanical Doll (IOI18_doll) C++14
53 / 100
89 ms 13960 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;
            }
 
            if(l<vis[i].size()-1)
            {
            X[id]=-(idx+1);
            X.pb(-(start+1));
            Y.pb(-(start+1));
            q.push({{d+1,idx},{l,l+(1<<d)}});
            }
            
            if(r==(1<<d)-1 || r<vis[i].size()-1)
            {
            idx++;
            Y[id]=-(idx+1);
            X.pb(-(start+1));
            Y.pb(-(start+1));
            q.push({{d+1,idx},{r,r+(1<<d)}});
            idx++;
            }
            
        }
    }
  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)
      |                    ~^~~~~~~~~~~~~~~~
doll.cpp:64:17: 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]
   64 |             if(l<vis[i].size()-1)
      |                ~^~~~~~~~~~~~~~~~
doll.cpp:72:32: 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]
   72 |             if(r==(1<<d)-1 || r<vis[i].size()-1)
      |                               ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 22 ms 6708 KB Output is correct
3 Correct 19 ms 5428 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 12 ms 4180 KB Output is correct
6 Correct 36 ms 8120 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 22 ms 6708 KB Output is correct
3 Correct 19 ms 5428 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 12 ms 4180 KB Output is correct
6 Correct 36 ms 8120 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 34 ms 7552 KB Output is correct
9 Correct 35 ms 8952 KB Output is correct
10 Correct 77 ms 11668 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 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 22 ms 6708 KB Output is correct
3 Correct 19 ms 5428 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 12 ms 4180 KB Output is correct
6 Correct 36 ms 8120 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 34 ms 7552 KB Output is correct
9 Correct 35 ms 8952 KB Output is correct
10 Correct 77 ms 11668 KB Output is correct
11 Correct 1 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 62 ms 11140 KB Output is correct
15 Correct 41 ms 6260 KB Output is correct
16 Correct 52 ms 8880 KB Output is correct
17 Correct 1 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 69 ms 10940 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Correct 35 ms 6148 KB Output is correct
3 Partially correct 70 ms 9176 KB Output is partially correct
4 Partially correct 54 ms 9908 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Correct 35 ms 6148 KB Output is correct
3 Partially correct 70 ms 9176 KB Output is partially correct
4 Partially correct 54 ms 9908 KB Output is partially correct
5 Partially correct 75 ms 12192 KB Output is partially correct
6 Partially correct 89 ms 12664 KB Output is partially correct
7 Partially correct 76 ms 12604 KB Output is partially correct
8 Partially correct 80 ms 12872 KB Output is partially correct
9 Partially correct 48 ms 9144 KB Output is partially correct
10 Partially correct 76 ms 13960 KB Output is partially correct
11 Partially correct 79 ms 13152 KB Output is partially correct
12 Partially correct 50 ms 9264 KB Output is partially correct
13 Partially correct 52 ms 8444 KB Output is partially correct
14 Partially correct 49 ms 8292 KB Output is partially correct
15 Partially correct 47 ms 8184 KB Output is partially correct
16 Partially correct 1 ms 468 KB Output is partially correct
17 Partially correct 41 ms 7060 KB Output is partially correct
18 Partially correct 43 ms 7128 KB Output is partially correct
19 Partially correct 43 ms 8280 KB Output is partially correct
20 Partially correct 77 ms 9916 KB Output is partially correct
21 Partially correct 67 ms 11712 KB Output is partially correct
22 Partially correct 60 ms 9284 KB Output is partially correct