QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#596666#5254. DifferencesQHhee004#TL 1933ms26888kbC++171.5kb2024-09-28 16:14:002024-09-28 16:14:00

Judging History

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

  • [2024-09-28 16:14:00]
  • 评测
  • 测评结果:TL
  • 用时:1933ms
  • 内存:26888kb
  • [2024-09-28 16:14:00]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <time.h>
#define chmx(x, y) x=max(x,y)
#define chmn(x, y) x=min(x,y)
//#define x first
//#define y second
using namespace std;
const int N = 2e5 + 5;
const int P = 131;
const int M = 1e6 + 10;
const int mod = 123456789;
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef pair<ll, ll>PII;
int n, m, k, ans,d[100010];
bool st[100010];
int cnt[100010][4];
string s[100010];
int Dis(string &a, string &b) {
    int res = 0;
    for (int i = 0; i < m; i++) {
        res += (a[i] != b[i]);
    }
    return res;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)cin >> s[i];
    for(int i=0; i<n; i++) {
    	for(int j=0; j<m; j++) {
    		cnt[j][s[i][j]-'A']++;
		}
	}
	for(int i=0; i<n; i++) {
		ll sum=0;
		for(int j=0; j<m; j++)
			for(int k=0; k<4; k++)
				if(s[i][j]-'A'!=k)sum=sum+cnt[j][k];
		if(sum!=1ll*(n-1)*k)st[i]=1;
	}
	for(int i=0; i<n; i++)d[i]=i;
	for(int i=0; i<n; i++)
		swap(d[rand()%n],d[rand()%n]);
	for(int i=0; i<n; i++) {
		int g=d[i];
		if(st[g])continue;
		bool flag=1;
		for(int j=0; j<m; j++) {
			if(g==d[j])continue;
			int dis=Dis(s[g],s[d[j]]);
			if(dis!=k) {
				st[g]=st[d[j]]=1;
				flag=0;
			}
		}
		if(flag){
			cout<<g+1<<'\n';
			break;
		}
	}
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1933ms
memory: 24700kb

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:

1397

result:

ok single line: '1397'

Test #2:

score: 0
Accepted
time: 135ms
memory: 26888kb

input:

4099 4100 2
ABABBAAABBBABBBAABAAAAABABBBBBAAAAABBABBBBABBAAABBAABAAAAAAAAABBABAABAABBAAABAAAABBAABBBBABAAABAABABBAAABBBBBABABBBBBABBABBAABBBABAAABBABBBBAAAABAABBAABAABABABAAABAAAAABAABABBBAAAABBBBBBBABBBAABABBABABBBABAAAAABBBBABAAABABBBAABBAABBBABBABBBABBAABABBABBBBABBBABAABBBAAABAABAABBABAAABABABAB...

output:

2964

result:

ok single line: '2964'

Test #3:

score: 0
Accepted
time: 157ms
memory: 26196kb

input:

4002 4096 2048
ABBBAAABAABBBABBBBABBBBBBBAABBABBBAABABBABBABBABBAABABBBBBAAAAABBBBBBAAAAAABAAAABBBABABAABBBABABAAAABBAABAABABBBABBBBABAAAABBBBBBABBBAAABABBABABAABBABAAABABBABABABAAAAAABABAABABAABBAAAABAAAAABBABAABBAAAAAAABBAAAAABABBABABAAAAABBABBBBBABABAABABBBAABBAAABBBBAAAAABBBBBBBABBBAABBAABBAABBB...

output:

3926

result:

ok single line: '3926'

Test #4:

score: -100
Time Limit Exceeded

input:

3892 4096 3072
CCBACBACABCBBCDBDBBDDABDADCDCCAABAAADADDCBABABACAACCADDDAAACBCDACCBDBCCCACACBBBCADBBDBABDACAABADBBBADADADBAADBCCDBDAADCCBDCBDBAACAABDABDAADBBCDDCADDBBDBDBDDBBDACCCCACBACCBADDCCDCDCCACBCDDCDCCCADCDDAADBBDABAADBDDDACBDBDDDBACDAABBBDDABACAACDAADBBBCDCCCAAAADDCBDBBCBDDADCAACCAABBCCBDBABCB...

output:


result: