제출 #1018318

#제출 시각아이디문제언어결과실행 시간메모리
1018318andrewpDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h"
#include "bits/stdc++.h"

using namespace std;
int ps[1e5+1][3][2], pr[1e5+1][6];

void init(std::string a, std::string b) {
    int n=a.size();
    a='i'+a, b='i'+b;
    for(int i=1; i<=n; ++i) {
        ps[i][0][0]=ps[i-1][0][0];
        ps[i][1][0]=ps[i-1][1][0];
        ps[i][2][0]=ps[i-1][2][0];
        ps[i][0][1]=ps[i-1][0][1];
        ps[i][1][1]=ps[i-1][1][1];
        ps[i][2][1]=ps[i-1][2][1];
        if(a[i]=='A') ++ps[i][0][0];
        else if(a[i]=='C') ++ps[i][1][0];
        else ++ps[i][2][0];
        if(b[i]=='A') ++ps[i][0][1];
        else if(b[i]=='C') ++ps[i][1][1];
        else ++ps[i][2][1];
        for(int j=0; j<6; ++j) pr[i][j]=pr[i-1][j];
        if(a[i]=='A'&&b[i]=='C') ++pr[i][0];
        if(a[i]=='C'&&b[i]=='A') ++pr[i][1];
        if(a[i]=='A'&&b[i]=='T') ++pr[i][2];
        if(a[i]=='T'&&b[i]=='A') ++pr[i][3];
        if(a[i]=='C'&&b[i]=='T') ++pr[i][4];
        if(a[i]=='T'&&b[i]=='C') ++pr[i][5];
    }
}

int get_distance(int x, int y) {
    ++x, ++y;
    for(int i=0; i<3; ++i) {
        if((ps[y][i][0]-ps[x-1][i][0])!=(ps[y][i][1]-ps[x-1][i][1])) {
            return -1;
        }
    }
    vector<int> v;
    for(int i=0; i<6; ++i) v.push_back(pr[y+1][i]-pr[x][0]);
    int p=min(v[0], v[1]), q=min(v[2], v[3]), r=min(v[4], v[5]);
    v[0]-=p, v[1]-=p;
    int ans=p+q+r;
    ans+=2*max(v[0], v[1]);
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

dna.cpp:5:11: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    5 | int ps[1e5+1][3][2], pr[1e5+1][6];
      |        ~~~^~
dna.cpp:5:11: error: could not convert '(1.0e+5 + (double)1)' from 'double' to 'long unsigned int'
dna.cpp:5:11: error: size of array 'ps' has non-integral type 'double'
dna.cpp:5:28: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    5 | int ps[1e5+1][3][2], pr[1e5+1][6];
      |                         ~~~^~
dna.cpp:5:28: error: could not convert '(1.0e+5 + (double)1)' from 'double' to 'long unsigned int'
dna.cpp:5:28: error: size of array 'pr' has non-integral type 'double'