제출 #541830

#제출 시각아이디문제언어결과실행 시간메모리
541830YassineBenYounesMutating DNA (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define vi vector<int>
#define vll vector<pair<ll, ll>>
#define vii vector<pair<int, int>>
#define pb push_back
#define ff first
#define ss second

string a, b;

int get_distance(int x, int y){
    string one = a.substr(x, y - x + 1);
    string two = b.substr(x, y - x + 1);
    int c = 0;
    for(int i = 0; i < one.size();i++){
        if(one[i] != two[i]){
            int index = -1;
            for(int x = i + 1; x < a.size();x++){
                if(one[x] == two[i]){
                    index = x;break;
                }
            }
            if(index == -1)return -1;
            else{
                swap(one[i], one[index]);
                c++;
            }
        }
    }
    return c;
}
/*
5
1
ATACAT
ACTATA
1 3
*/
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    cin >> a >> b;
    while(q--){
        int x, y;cin >> x >> y;
        cout << get_distance(x, y) << endl;
    }
}

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i = 0; i < one.size();i++){
      |                    ~~^~~~~~~~~~~~
dna.cpp:22:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             for(int x = i + 1; x < a.size();x++){
      |                                ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccRNGorJ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccnsAl0L.o:dna.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccRNGorJ.o: in function `main':
grader.cpp:(.text.startup+0x366): undefined reference to `init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: error: ld returned 1 exit status