QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#643196#7879. Colorful BalloonsE_REMALWA 0ms3540kbC++14735b2024-10-15 19:42:282024-10-15 19:42:28

Judging History

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

  • [2024-10-15 19:42:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3540kb
  • [2024-10-15 19:42:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn1=1e3+5,maxn2=1e5+5;
int n,m,c,cnt;
long long ans;
bool b;
int color[maxn2];
struct node {
	int x;
	int y;
}p;
vector <node> v[maxn1];
int main()
{
	cin>>n>>m;
	cnt=0;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			cin>>c;
			p.x=i;
			p.y=j;
			b=0;
			for(int k=1;k<=cnt;k++) {
				if(color[k]==c) {
					v[k].push_back(p);
					b=1;
				}
			}
			if(b==0) {
				v[++cnt].push_back(p);
				color[cnt]=c;
			}
		}
	}
	for(int i=1;i<=cnt;i++) {
		for(int j=0;j<v[i].size()-1;j++) {
			for(int k=j+1;k<v[i].size();k++) {
				ans+=(abs(v[i][j].x-v[i][k].x)+abs(v[i][j].y-v[i][k].y))*2;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3540kb

input:

5
red
green
red
red
blue

output:

0

result:

wrong answer 1st words differ - expected: 'red', found: '0'