제출 #1001665

#제출 시각아이디문제언어결과실행 시간메모리
1001665vjudge1Mutating DNA (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define f first #define s second #define pb push_back #define pf push_front #define pi pair<int,int> string a,b; const int MAX = 1e5+1; int n; ll how[2][MAX][3]; map<char,int>mtch; void init(string A, string B){ a = A; b = B; mtch['A']=0; mtch['C']=1; mtch['T']=2; for(int i = 0; i <a.size(); i++){ for(int j = 0; j<3; j++){ how[0][i+1][j] = how[0][i][j] ; how[1][i+1][j] = how[1][i][j] ; } // cout << mtch[A[i]]<<" s "<< mtch[B[i]]<<endl; how[0][i+1][mtch[A[i]]]++; how[1][i+1][mtch[B[i]]]++; } } int get_distance(int x, int y){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); ll add = 0; ll sub = 0; ll mp[3]; memset(mp,0,sizeof(mp)); int vala,valb; for(int i =0; i < 3; i++){ vala = how[0][y+1][i]-how[0][x][i]; valb = how[1][y+1][i]-how[1][x][i]; if(vala!=valb) return -1; } for(int i = x; i<= y; i++){ if(a[i]!=b[i]){ add++; // cout << a[i]<< " " << mtch[a[i]]<<endl; if(mp[mtch[a[i]]]){ sub++; mp[mtch[a[i]]]--; } else mp[mtch[b[i]]]++; } } //cout << add<<" "<<sub<< " "<< endl; return add-sub; } int main(){ int n,q ; cin >> n >> q; string a,b; cin >> a >>b; init(a,b); int x,y; while(q--){ cin >> x >>y; cout << get_distance(x,y)<<endl; } }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:22:22: 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 i = 0; i <a.size(); i++){
      |                    ~~^~~~~~~~~
/usr/bin/ld: /tmp/ccVQP30J.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccbZ5JjL.o:dna.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status