Submission #595322

# Submission time Handle Problem Language Result Execution time Memory
595322 2022-07-13T15:29:58 Z Ahmadsm2005 Unscrambling a Messy Bug (IOI16_messy) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "messy.h"
#include "grader.cpp"
using namespace std;
string arr[]={"0001","0010","0011","0100","0101","0110","0111","1001"};
int SZ[]={15,15,15,15,16,16,16,16},N,POS[]={-1,-1,-1,-1};
vector<int>YAY[8];
void SET(int CUR,int idx){
string S="";
S+=arr[CUR];
for(int i=4;i<N;i++)
S+='0';
S[idx]='1';
add_element(S);
}
void SET2(int CUR,int idx,int idx2){
string S="1111";
for(int i=4;i<N;i++)
S+='0';
for(int i=idx2;i<=idx;i++)
S[i]='1';
add_element(S);
}
void SET3(string &s,int X){
for(int i=0;i<4;i++){
s[POS[i]]=arr[X][i];
}
}
vector<int> restore_permutation(int n, int w, int r){
    N=n;
    vector<int>ANS(n);
    string s="";
    for(int i=0;i<n;i++)
    s+='0';
    s[0]='1';
    add_element(s);
    s[1]='1';
    add_element(s);
    s[2]='1';
    add_element(s);
    s[3]='1';
    add_element(s);
    int CUR=0,l=0;
    for(int i=4;i<n;i++){
    SET(CUR,i);
    SET2(CUR,i,l);
    SZ[CUR]--;
    if(!SZ[CUR])
    CUR++,l=i+1;
    }
    compile_set();
    string SS="";
    for(int i=0;i<n;i++){
    SS+='0';
    }
    for(int l=0;l<4;l++){
    for(int i=0;i<n;i++){
    if(SS[i]!='1'){
    SS[i]='1';
    if(check_element(SS)){
    POS[l]=i;
    ANS[i]=l;
    break;
    }
    SS[i]='0';
    }
    }
    }
    for(int i=0;i<n;i++){
    if(POS[0]==i||POS[1]==i||POS[2]==i||POS[3]==i)
    continue;
    for(int l=0;l<7;l++){
    string F="";
    for(int z=0;z<n;z++)
    F+='0';
    SET3(F,l);
    F[i]='1';
    if(check_element(F)){
    YAY[l].push_back(i);
    goto a;
    }
    }
    YAY[7].push_back(i);
    a:;
    }
    //for(int i=0;i<8;i++)
    //cout<<YAY[i].size()<<' ';
    //cout<<endl;
    int GC=4;
    for(int i=0;i<8;i++){
    string F="";
    for(int z=0;z<n;z++)
    F+='0';
    F[POS[0]]=F[POS[1]]=F[POS[2]]=F[POS[3]]='1';
    for(int x=0;x<YAY[i].size();x++){
    for(int l=0;l<YAY[i].size();l++){
    if(F[YAY[i][l]]=='0'){
    F[YAY[i][l]]='1';
    if(check_element(F)){
    ANS[YAY[i][l]]=GC;
    GC++;
    break;
    }
    F[YAY[i][l]]='0';
    }
    }
    }
    }
    vector<int>F;
    for(int i=0;i<n;i++)
    F.push_back(ANS[i]);
    //cout<<F.size()<<endl;
    return F;
}

Compilation message

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:95:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |     for(int x=0;x<YAY[i].size();x++){
      |                 ~^~~~~~~~~~~~~~
messy.cpp:96:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |     for(int l=0;l<YAY[i].size();l++){
      |                 ~^~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccVSFgPw.o: in function `helper::read_int()':
grader.cpp:(.text+0x860): multiple definition of `helper::read_int()'; /tmp/ccACOwVu.o:messy.cpp:(.text+0x450): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o: in function `get_p(int)':
grader.cpp:(.text+0x8b0): multiple definition of `get_p(int)'; /tmp/ccACOwVu.o:messy.cpp:(.text+0x4a0): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o:(.bss+0x10): multiple definition of `helper::p'; /tmp/ccACOwVu.o:(.bss+0x1f0): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o: in function `wa()':
grader.cpp:(.text+0x8d0): multiple definition of `wa()'; /tmp/ccACOwVu.o:messy.cpp:(.text+0x4c0): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o: in function `check(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
grader.cpp:(.text+0x900): multiple definition of `check(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'; /tmp/ccACOwVu.o:messy.cpp:(.text+0x4f0): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o:(.bss+0x28): multiple definition of `helper::n'; /tmp/ccACOwVu.o:(.bss+0x208): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o: in function `check_element(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x950): multiple definition of `check_element(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/ccACOwVu.o:messy.cpp:(.text+0x540): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o:(.bss+0x0): multiple definition of `helper::r'; /tmp/ccACOwVu.o:(.bss+0x1e0): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o:(.bss+0x2c): multiple definition of `helper::compiled'; /tmp/ccACOwVu.o:(.bss+0x20c): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o:(.bss+0x40): multiple definition of `helper::set_[abi:cxx11]'; /tmp/ccACOwVu.o:(.bss+0x220): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccACOwVu.o:messy.cpp:(.text.startup+0xc0): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o:(.bss+0x4): multiple definition of `helper::w'; /tmp/ccACOwVu.o:(.bss+0x1e4): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o: in function `add_element(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0xad0): multiple definition of `add_element(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/ccACOwVu.o:messy.cpp:(.text+0x710): first defined here
/usr/bin/ld: /tmp/ccVSFgPw.o: in function `compile_set()':
grader.cpp:(.text+0xb30): multiple definition of `compile_set()'; /tmp/ccACOwVu.o:messy.cpp:(.text+0xcb0): first defined here
collect2: error: ld returned 1 exit status