답안 #615009

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
615009 2022-07-31T06:08:13 Z 조영욱(#8494) Broken Device 2 (JOI22_device2) C++17
13 / 100
626 ms 253968 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

int cnt=0;
typedef pair<int,int> P;
P val[20000000];
int m=2000;
}

int Declare() {
  return 2000;
}

std::pair<std::vector<int>, std::vector<int> > Anna(long long A) {
    if (cnt==0) {
        int now=1;
        for(int i=1;i<=m;i++){
            for(int j=0;j<=2*i;j++) {
                if (j>=4&&j<=2*i-4) {
                    val[now]=P(i,j);
                    val[now+1]=P(i,j);
                    val[now+2]=P(i,j);
                    val[now+3]=P(i,j);
                    now+=4;
                }
                else {
                    val[now]=P(i,j);
                    now++;
                }
            }
        }
    }
    cnt++;
    vector<int> one;
    vector<int> two;
    P now=val[A];
    int ind=A;
    while (ind>0&&val[ind]==now) {
        ind--;
    }
    ind++;
    int left=now.second;
    if (now.second<4||now.second>2*now.first-4) {
        for(int i=0;i<now.first;i++) {
            if (left>0) {
                one.push_back(1);
                left--;
            }
            else {
                one.push_back(0);
            }
        }
        for(int i=0;i<now.first;i++) {
            if (left>0) {
                two.push_back(1);
                left--;
            }
            else {
                two.push_back(0);
            }
        }
    }
    else if (A-ind==0) {
        for(int i=0;i<now.first;i++) {
            if (i==0) {
                one.push_back(0);
            }
            else if (i==now.first-1) {
                one.push_back(0);
            }
            else if (left>0) {
                one.push_back(1);
                left--;
            }
            else {
                one.push_back(0);
            }
        }
        for(int i=0;i<now.first;i++) {
            if (i==0) {
                two.push_back(0);
            }
            else if (i==now.first-1) {
                two.push_back(0);
            }
            else if (left>0) {
                two.push_back(1);
                left--;
            }
            else {
                two.push_back(0);
            }
        }
    }
    else if (A-ind==1) {
        left-=2;
        for(int i=0;i<now.first;i++) {
            if (i==0) {
                one.push_back(0);
            }
            else if (i==now.first-1) {
                one.push_back(1);
            }
            else if (left>0) {
                one.push_back(1);
                left--;
            }
            else {
                one.push_back(0);
            }
        }
        for(int i=0;i<now.first;i++) {
            if (i==0) {
                two.push_back(0);
            }
            else if (i==now.first-1) {
                two.push_back(1);
            }
            else if (left>0) {
                two.push_back(1);
                left--;
            }
            else {
                two.push_back(0);
            }
        }
    }
    else if (A-ind==2) {
            left-=2;
        for(int i=0;i<now.first;i++) {
            if (i==0) {
                one.push_back(1);
            }
            else if (i==now.first-1) {
                one.push_back(0);
            }
            else if (left>0) {
                one.push_back(1);
                left--;
            }
            else {
                one.push_back(0);
            }
        }
        for(int i=0;i<now.first;i++) {
            if (i==0) {
                two.push_back(1);
            }
            else if (i==now.first-1) {
                two.push_back(0);
            }
            else if (left>0) {
                two.push_back(1);
                left--;
            }
            else {
                two.push_back(0);
            }
        }
    }
    else if (A-ind==3) {
            left-=4;
        for(int i=0;i<now.first;i++) {
            if (i==0) {
                one.push_back(1);
            }
            else if (i==now.first-1) {
                one.push_back(1);
            }
            else if (left>0) {
                one.push_back(1);
                left--;
            }
            else {
                one.push_back(0);
            }
        }
        for(int i=0;i<now.first;i++) {
            if (i==0) {
                two.push_back(1);
            }
            else if (i==now.first-1) {
                two.push_back(1);
            }
            else if (left>0) {
                two.push_back(1);
                left--;
            }
            else {
                two.push_back(0);
            }
        }
    }
  return make_pair(one,two);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

int cnt=0;
int st[2001][4001];
}

long long Bruno(std::vector<int> u) {
    if (cnt==0) {
        int now=1;
        for(int i=1;i<=2000;i++){
            for(int j=0;j<=2*i;j++) {
                if (j>=4&&j<=2*i-4) {
                    st[i][j]=now;
                    now+=4;
                }
                else {
                    st[i][j]=now;
                    now++;
                }
            }
        }
    }
    cnt++;
    int one=0;
    int m=u.size()/2;
    for(int i=0;i<u.size();i++) {
        //printf("%d ",u[i]);
        if (u[i]==1) {
            one++;
        }
    }
    //printf("\n");
    int now=st[m][one];
    int bit=0;
    if (one>=4&&one<=2*m-4) {
        if (u[0]==1) {
            bit+=2;
        }
        if (u[2*m-1]==1) {
            bit++;
        }
    }
    //printf(".%d %d %d %d\n",now,m,one,bit);
  return now+bit;
}

Compilation message

Bruno.cpp: In function 'long long int Bruno(std::vector<int>)':
Bruno.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=0;i<u.size();i++) {
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 148220 KB Output is correct
2 Correct 81 ms 148524 KB Output is correct
3 Correct 99 ms 148620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 148220 KB Output is correct
2 Correct 81 ms 148524 KB Output is correct
3 Correct 99 ms 148620 KB Output is correct
4 Correct 343 ms 159204 KB Output is correct
5 Correct 330 ms 159368 KB Output is correct
6 Correct 373 ms 159452 KB Output is correct
7 Correct 379 ms 159028 KB Output is correct
8 Correct 358 ms 159400 KB Output is correct
9 Correct 470 ms 164204 KB Output is correct
10 Correct 500 ms 164240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 148220 KB Output is correct
2 Correct 81 ms 148524 KB Output is correct
3 Correct 99 ms 148620 KB Output is correct
4 Correct 343 ms 159204 KB Output is correct
5 Correct 330 ms 159368 KB Output is correct
6 Correct 373 ms 159452 KB Output is correct
7 Correct 379 ms 159028 KB Output is correct
8 Correct 358 ms 159400 KB Output is correct
9 Correct 470 ms 164204 KB Output is correct
10 Correct 500 ms 164240 KB Output is correct
11 Correct 485 ms 165792 KB Output is correct
12 Correct 462 ms 165384 KB Output is correct
13 Correct 461 ms 165176 KB Output is correct
14 Correct 452 ms 165316 KB Output is correct
15 Correct 465 ms 165164 KB Output is correct
16 Correct 626 ms 173564 KB Output is correct
17 Correct 621 ms 173548 KB Output is correct
18 Correct 380 ms 160880 KB Output is correct
19 Correct 419 ms 161036 KB Output is correct
20 Correct 354 ms 160596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 148220 KB Output is correct
2 Correct 81 ms 148524 KB Output is correct
3 Correct 99 ms 148620 KB Output is correct
4 Correct 343 ms 159204 KB Output is correct
5 Correct 330 ms 159368 KB Output is correct
6 Correct 373 ms 159452 KB Output is correct
7 Correct 379 ms 159028 KB Output is correct
8 Correct 358 ms 159400 KB Output is correct
9 Correct 470 ms 164204 KB Output is correct
10 Correct 500 ms 164240 KB Output is correct
11 Correct 485 ms 165792 KB Output is correct
12 Correct 462 ms 165384 KB Output is correct
13 Correct 461 ms 165176 KB Output is correct
14 Correct 452 ms 165316 KB Output is correct
15 Correct 465 ms 165164 KB Output is correct
16 Correct 626 ms 173564 KB Output is correct
17 Correct 621 ms 173548 KB Output is correct
18 Correct 380 ms 160880 KB Output is correct
19 Correct 419 ms 161036 KB Output is correct
20 Correct 354 ms 160596 KB Output is correct
21 Runtime error 158 ms 253968 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 148220 KB Output is correct
2 Correct 81 ms 148524 KB Output is correct
3 Correct 99 ms 148620 KB Output is correct
4 Correct 343 ms 159204 KB Output is correct
5 Correct 330 ms 159368 KB Output is correct
6 Correct 373 ms 159452 KB Output is correct
7 Correct 379 ms 159028 KB Output is correct
8 Correct 358 ms 159400 KB Output is correct
9 Correct 470 ms 164204 KB Output is correct
10 Correct 500 ms 164240 KB Output is correct
11 Correct 485 ms 165792 KB Output is correct
12 Correct 462 ms 165384 KB Output is correct
13 Correct 461 ms 165176 KB Output is correct
14 Correct 452 ms 165316 KB Output is correct
15 Correct 465 ms 165164 KB Output is correct
16 Correct 626 ms 173564 KB Output is correct
17 Correct 621 ms 173548 KB Output is correct
18 Correct 380 ms 160880 KB Output is correct
19 Correct 419 ms 161036 KB Output is correct
20 Correct 354 ms 160596 KB Output is correct
21 Runtime error 158 ms 253968 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 161 ms 253852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -