QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#71370#5254. DifferencesSorting#TL 592ms23308kbC++634b2023-01-09 21:03:122023-01-09 21:03:15

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-09 21:03:15]
  • 评测
  • 测评结果:TL
  • 用时:592ms
  • 内存:23308kb
  • [2023-01-09 21:03:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
int n,m,k;
string s[100001];
int p[100001];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m >> k;
	for(int i=1; i<=n ;i++){
		cin >> s[i];
		p[i]=i;
	}
	random_shuffle(p+1,p+n+1);
	for(int i=1; i<=n ;i++){
		bool fail=false;
		for(int j=1; j<=n ;j++){
			if(i==p[j]) continue;
			int x=0;
			for(int k=0; k<m ;k++) x+=s[i][k]!=s[p[j]][k];
			//cout << i << ' ' << p[j] << ' ' << x << endl;
			if(x!=k){
				fail=true;
				break;
			}
		}
		if(!fail) return cout << i << '\n',0;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 592ms
memory: 23308kb

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:

1397

result:

ok single line: '1397'

Test #2:

score: -100
Time Limit Exceeded

input:

4099 4100 2
ABABBAAABBBABBBAABAAAAABABBBBBAAAAABBABBBBABBAAABBAABAAAAAAAAABBABAABAABBAAABAAAABBAABBBBABAAABAABABBAAABBBBBABABBBBBABBABBAABBBABAAABBABBBBAAAABAABBAABAABABABAAABAAAAABAABABBBAAAABBBBBBBABBBAABABBABABBBABAAAAABBBBABAAABABBBAABBAABBBABBABBBABBAABABBABBBBABBBABAABBBAAABAABAABBABAAABABABAB...

output:


result: