제출 #1141931

#제출 시각아이디문제언어결과실행 시간메모리
1141931rayankMutating DNA (IOI21_dna)C++20
컴파일 에러
0 ms0 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; string A; string B; void init(string a, string b) { A = a; B = b; } int find_pos(char c, string s, int start, int end){ for(int i = start; i <= end; i++){ if(s[i] == c){ return i; } } return -1; } bool issamee(string a, string b, int start, int end){ for(int i = start; i <= end; i++){ if(a[i] != b[i]){ return false; } } return true; } int get_distance(int x, int y) { int res = 0; string acopy = A; for(int i=x; i <=y;i++){ if(acopy[i] == B[i]) continue; int pos = find_pos(acopy[i], B, x, y); if(pos == -1) return -1; swap(acopy[i], acopy[pos]); res++; } for(int i=y; i >=x;i--){ if(acopy[i] == B[i]) continue; int pos = find_pos(acopy[i], B, x, y); if(pos == -1) return -1; swap(acopy[i], acopy[pos]); res++; } if(!issamee(acopy, B, x, y)) return -1; return res; } int main() { int n,q; cin>>n>>q; string a,b; cin>>a>>b; init(a,b); while(q--){ int x,y; cin>>x>>y; cout<<get_distance(x,y)<<endl; } }

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

/usr/bin/ld: /tmp/cc2oKeFc.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccGfT7gm.o:dna.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status