답안 #595324

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595324 2022-07-13T15:30:26 Z Ahmadsm2005 Unscrambling a Messy Bug (IOI16_messy) C++14
59 / 100
3 ms 412 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++){
      |                 ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 8
2 Correct 1 ms 296 KB n = 8
3 Correct 0 ms 212 KB n = 8
4 Correct 0 ms 212 KB n = 8
5 Correct 0 ms 212 KB n = 8
6 Correct 1 ms 300 KB n = 8
7 Correct 1 ms 212 KB n = 8
8 Correct 1 ms 292 KB n = 8
9 Correct 1 ms 212 KB n = 8
10 Correct 0 ms 212 KB n = 8
11 Correct 0 ms 292 KB n = 8
12 Correct 1 ms 212 KB n = 8
13 Correct 1 ms 212 KB n = 8
14 Correct 1 ms 212 KB n = 8
15 Correct 0 ms 212 KB n = 8
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB n = 32
2 Correct 1 ms 212 KB n = 32
3 Correct 1 ms 212 KB n = 32
4 Correct 0 ms 212 KB n = 32
5 Correct 1 ms 212 KB n = 32
6 Correct 1 ms 212 KB n = 32
7 Correct 1 ms 212 KB n = 32
8 Correct 1 ms 212 KB n = 32
9 Correct 1 ms 212 KB n = 32
10 Correct 1 ms 212 KB n = 32
11 Correct 1 ms 212 KB n = 32
12 Correct 1 ms 212 KB n = 32
13 Correct 1 ms 300 KB n = 32
14 Correct 1 ms 212 KB n = 32
15 Correct 1 ms 212 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 32
2 Correct 1 ms 212 KB n = 32
3 Incorrect 1 ms 212 KB grader returned WA
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB n = 128
2 Correct 2 ms 304 KB n = 128
3 Correct 2 ms 412 KB n = 128
4 Correct 2 ms 340 KB n = 128
5 Correct 2 ms 300 KB n = 128
6 Correct 2 ms 340 KB n = 128
7 Correct 2 ms 296 KB n = 128
8 Correct 2 ms 340 KB n = 128
9 Correct 3 ms 340 KB n = 128
10 Correct 2 ms 300 KB n = 128
11 Correct 2 ms 340 KB n = 128
12 Correct 2 ms 340 KB n = 128
13 Correct 2 ms 340 KB n = 128
14 Correct 2 ms 340 KB n = 128
15 Correct 2 ms 300 KB n = 128
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB grader returned WA
2 Halted 0 ms 0 KB -