제출 #510003

#제출 시각아이디문제언어결과실행 시간메모리
510003YaserFaisalDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> 
#include "dna.h"
using namespace std ;
 
int ps[100009][20] ;

void init ( string a , string b )
{
    int n = a.size() ;
    for ( int i = 0 ; i < n ; i++ )
    {
        if ( a[i] == 'A' && b[i] == 'C' ) ps[i+1][1]++ ;
        if ( a[i] == 'C' && b[i] == 'A' ) ps[i+1][2]++ ;
        if ( a[i] == 'C' && b[i] == 'T' ) ps[i+1][3]++ ;
        if ( a[i] == 'T' && b[i] == 'C' ) ps[i+1][4]++ ;
        if ( a[i] == 'T' && b[i] == 'A' ) ps[i+1][5]++ ;
        if ( a[i] == 'A' && b[i] == 'T' ) ps[i+1][6]++ ;
        if ( a[i] == 'A' ) ps[i+1][7]++ ;
        if ( a[i] == 'C' ) ps[i+1][8]++ ;
        if ( a[i] == 'T' ) ps[i+1][9]++ ;
        if ( b[i] == 'A' ) ps[i+1][10]++ ;
        if ( b[i] == 'C' ) ps[i+1][11]++ ;
        if ( b[i] == 'T' ) ps[i+1][12]++ ;
        for ( int j = 1 ; j <= 12 ; j++ ) ps[i+1][j]+=ps[i][j] ;  
    }
}
// ACT
// 1 AC 
// 2 CA 
// 3 CT 
// 4 TC 
// 5 TA
// 6 AT 
int get_distance ( int x , int y )
{
    y++ ;
    for ( int i = 7 ; i <= 9 ; i++ )
    {
        if ( (ps[y][i]-ps[x][i]) != (ps[y][i+3]-ps[x][i+3]) ) return -1 ;
    }
	int ans = 0 ;
    int a = ps[y][1] - ps[x][1] ;
    int b = ps[y][2] - ps[x][2] ;
    int c = ps[y][3] - ps[x][3] ;
    int d = ps[y][4] - ps[x][4] ;
    int e = ps[y][5] - ps[x][5] ;
    int f = ps[y][6] - ps[x][6] ;
    //cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl ;
    int fi = max(a,b) - min(a,b) ;
    ans+=min(a,b) ;
    int s = max(c,d) - min(c,d) ;
    ans+=min(c,d) ;
    int t = max(e,f) - min(e,f) ;
    ans+=min(e,f) ;
    ans+=2*fi ;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    string a , b ; cin >> a >> b ;
    init(a,b) ;
    int q ; cin >> q ;
    while(q--)
    {
        int x , y ; cin >> x >> y ;
        cout << get_distance(x,y) ;
    }

}

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:51:9: warning: unused variable 's' [-Wunused-variable]
   51 |     int s = max(c,d) - min(c,d) ;
      |         ^
dna.cpp:53:9: warning: unused variable 't' [-Wunused-variable]
   53 |     int t = max(e,f) - min(e,f) ;
      |         ^
dna.cpp:55:8: warning: control reaches end of non-void function [-Wreturn-type]
   55 |     ans+=2*fi ;
      |     ~~~^~~~~~
/usr/bin/ld: /tmp/ccpGNXB7.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccBEvw94.o:dna.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status