Submission #766836

# Submission time Handle Problem Language Result Execution time Memory
766836 2023-06-26T08:04:17 Z DJeniUp Mechanical Doll (IOI18_doll) C++17
2 / 100
1000 ms 10296 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

typedef int ll;

#define pb push_back
#define fr first
#define sc second

ll h,a[200007],b[200007],f[200007];

vector<ll>v[200007];

vector<ll>c,x,y;

void create_circuit(int M, std::vector<int> A) {
    A.pb(0);
    for(int i=0;i<A.size()-1;i++){
        v[A[i]].pb(A[i+1]);
    }
    c.pb(A[0]);
    for(int i=1;i<=M;i++){
        if(v[i].size()==0)c.pb(0);
        else if(v[i].size()==1)c.pb(v[i][0]);
        else{
            h++;
            x.pb(-h);
            y.pb(-h);
            c.pb(-h);
            for(int j=0;j<v[i].size();j++){
                ll k=-c[i]-1;
                while(1){
                    if(f[k]%2==0){
                        f[k]++;
                        if(x[k]==0){
                            x[k]=v[i][j];
                            break;
                        }else if(x[k]<0){
                            k=-x[k]-1;
                        }else{
                            h++;
                            f[h-1]=1;
                            x.pb(-h);
                            y.pb(-h);
                            x[h-1]=x[k];
                            x[k]=-h;
                            k=h-1;
                        }
                    }else{
                        f[k]++;
                        if(y[k]==0){
                            y[k]=v[i][j];
                            break;
                        }else if(y[k]<0){
                            k=-y[k]-1;
                        }else{
                            h++;
                            f[h-1]=1;
                            x.pb(-h);
                            y.pb(-h);
                            x[h-1]=y[k];
                            y[k]=-h;
                            k=h-1;
                        }
                    }
                }
            }
        }
    }
    //cout<<c.size()<<" "<<x.size()<<" "<<y.size()<<endl;
    for(int i=0;i<=M;i++){
       // cout<<i<<" "<<c[i]<<endl;
    }
    for(int i=0;i<x.size();i++){
       // cout<<-i-1<<" "<<x[i]<<" "<<y[i]<<endl;
    }
    answer(c,x,y);
    return ;
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i=0;i<A.size()-1;i++){
      |                 ~^~~~~~~~~~~
doll.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             for(int j=0;j<v[i].size();j++){
      |                         ~^~~~~~~~~~~~
doll.cpp:75:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 19 ms 8788 KB Output is correct
3 Correct 15 ms 8400 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 10 ms 6220 KB Output is correct
6 Correct 24 ms 10296 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 19 ms 8788 KB Output is correct
3 Correct 15 ms 8400 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 10 ms 6220 KB Output is correct
6 Correct 24 ms 10296 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Execution timed out 1063 ms 8092 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 19 ms 8788 KB Output is correct
3 Correct 15 ms 8400 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 10 ms 6220 KB Output is correct
6 Correct 24 ms 10296 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Execution timed out 1063 ms 8092 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 4948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 4948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 4948 KB Time limit exceeded
2 Halted 0 ms 0 KB -