QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#643196 | #7879. Colorful Balloons | E_REMAL | WA | 0ms | 3540kb | C++14 | 735b | 2024-10-15 19:42:28 | 2024-10-15 19:42:28 |
Judging History
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'