이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("03")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int y;
int comp(string a, string b){
int r = 0;
for (int i = 0; i < a.size(); i++)if (a[i] != b[i])r++;
return r;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k; cin >> n >> m >> k;
if (n <= 100 && m <= 100){
string x[n];
for (int i = 0; i < n; i++)cin >> x[i];
for (int i = 0; i < n; i++){
bool flag10 = 1;
for (int j = 0; j < n; j++){
if (i == j)continue;
if (comp(x[i], x[j]) != k){
flag10 = 0;
break;
}
}
if (flag10){
cout << i+1;
break;
}
}
}
else {
bitset <4100> b[n];
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
char c; cin >> c;
if (c == 'A')b[i].set(j);
}
}
for (int i = 1500; i < n-1499; i++){
bool flag10 = 1;
int x = min(n, 1500);
for (int j = 0; j < x; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
if (flag10){
x = max(0, n-1499);
for (int j = n-1; j >= x; j--){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
for (int j = 1500; j < n-1499; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
for (int j = 2000; j < n-1499; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
int x = min(n, 2000);
for (int j = 1500; j < x; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
cout << i+1;
return 0;
}
}
y = min(n, 1500);
for (int i = 0; i < y; i++){
bool flag10 = 1;
int x = min(n, 1500);
for (int j = 0; j < x; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
if (flag10){
x = max(0, n-1499);
for (int j = n-1; j >= x; j--){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
for (int j = 1500; j < n-1499; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
for (int j = 2000; j < n-1499; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
int x = min(n, 2000);
for (int j = 1500; j < x; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
cout << i+1;
return 0;
}
}
y = max(0, n-1499);
for (int i = n-1; i >= y; i--){
bool flag10 = 1;
int x = min(n, 1500);
for (int j = 0; j < x; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
if (flag10){
x = max(0, n-1499);
for (int j = n-1; j >= x; j--){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
for (int j = 1500; j < n-1499; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
for (int j = 2000; j < n-1499; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
int x = min(n, 2000);
for (int j = 1500; j < x; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
cout << i+1;
return 0;
}
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
genetics.cpp: In function 'int comp(std::string, std::string)':
genetics.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for (int i = 0; i < a.size(); i++)if (a[i] != b[i])r++;
| ~~^~~~~~~~~~
genetics.cpp: In function 'int main()':
genetics.cpp:53:41: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
53 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:62:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
62 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:71:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
71 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:80:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
80 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:90:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
90 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:107:41: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
107 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:116:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
116 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:125:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
125 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:134:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
134 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:144:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
144 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:161:41: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
161 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:170:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
170 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:179:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
179 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:188:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
188 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:198:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
198 | if ((b[i]^b[j]).count() != k){
| ~~~~~~~~~~~~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |