제출 #777790

#제출 시각아이디문제언어결과실행 시간메모리
777790TheSahibGenetics (BOI18_genetics)C++14
27 / 100
2054 ms4132 KiB
#include <bits/stdc++.h> #define ll long long #define oo 1e9 #define pii pair<int, int> using namespace std; const int MAX = 5005; int n, m, k; string arr[MAX]; int comp(string& a, string& b){ int cnt = 0; for (int i = 0; i < m; i++) { cnt += (a[i] != b[i]); } return cnt; } void solve(){ scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < n; i++) { getchar(); for (int j = 0; j < m; j++) { char c = getchar(); arr[i] += c; } } vector<int> v; v.resize(n); iota(v.begin(), v.end(), 0); srand(time(0)); random_shuffle(v.begin(), v.end()); vector<int> p; for(int i:v){ if(i == v[0]) continue; if(comp(arr[i], arr[v[0]]) == k){ p.push_back(i); } } if(p.size() == n - 1){ cout << v[0] + 1 << '\n'; return; } for(int i:p){ bool pos = true; for(int j:v){ if(i == j) continue; if(comp(arr[i], arr[j]) != k){ pos = false; break; } } if(pos){ cout << i + 1 << '\n'; return; } } } int main() { solve(); }

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

genetics.cpp: In function 'void solve()':
genetics.cpp:49:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |     if(p.size() == n - 1){
      |        ~~~~~~~~~^~~~~~~~
genetics.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d%d%d", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...