제출 #497217

#제출 시각아이디문제언어결과실행 시간메모리
497217Maqsut_03DNA 돌연변이 (IOI21_dna)C++17
0 / 100
786 ms3088 KiB
#include<bits/stdc++.h> #include "dna.h" using namespace std; string a, b, a1, b1; int n; int arr[26]; void init(string a0, string b0) { a = a0; b = b0; a1 = a; b1 = b; n = a.length(); } int get_distance(int x, int y) { int ans = 0; a = a1; b = b1; memset(arr, 0, sizeof(arr)); for (int i = x; i <= y; i++) arr[a[i]]++, arr[b[i]]--; for (int i = 0; i < 26; i++) if (arr[i] != 0) return -1; a = a.substr(x, y); b = b.substr(x, y); // cout << a << " " << b << "\n"; for (int i = 0; i <= y - x; i++) for (int j = i; j <= y - x; j++){ if (a[j] == b[i] && i != j) { ans ++; swap(a[i], a[j]); } } return ans; }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:24:21: warning: array subscript has type 'char' [-Wchar-subscripts]
   24 |             arr[a[i]]++, arr[b[i]]--;
      |                     ^
dna.cpp:24:34: warning: array subscript has type 'char' [-Wchar-subscripts]
   24 |             arr[a[i]]++, arr[b[i]]--;
      |                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...