# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1016793 |
2024-07-08T12:27:45 Z |
vjudge1 |
Tenis (COCI20_tenis) |
C++17 |
|
83 ms |
9296 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
int n;
cin>>n;
int r[n][3],x;
for (int j=0;j<3;j++)
for (int i=0;i<n;i++)
{
cin>>x;
r[x-1][j]=i;
}
vector<int> bestr[n];
for (int i=0;i<n;i++)
{
int mn=r[i][0];
for (int j=1;j<3;j++)
mn=min(mn,r[i][j]);
bestr[mn].push_back(i);
}
int wins[n],court[3]={},cnt=0;
for (int i=n-1;i>=0;i--)
{
for (int j:bestr[i])
wins[j]=cnt;
cnt+=bestr[i].size();
for (int j=0;j<bestr[i].size();j++)
for (int k=j+1;k<bestr[i].size();k++)
{
int cor=-1,mn=n;
for (int c=0;c<3;c++)
{
if (r[bestr[i][j]][c]>i && r[bestr[i][k]][c]>i)
continue;
if (r[bestr[i][j]][c]==i)
if (mn>r[bestr[i][k]][c])
cor=c,mn=r[bestr[i][k]][c];
if (r[bestr[i][k]][c]==i)
if (mn>r[bestr[i][j]][c])
cor=c,mn=r[bestr[i][j]][c];
}
court[cor]++;
if (r[bestr[i][j]][cor]==i)
wins[bestr[i][j]]++;
else
wins[bestr[i][k]]++;
}
}
cnt=0;
int idk[3][3]={},bst[3]={};
for (int i=n-1;i>=0;i--)
{
for (int j:bestr[i])
{
vector<int> v;
for (int c=0;c<3;c++)
if (r[j][c]==i)
v.push_back(c);
if (v.size()==1)
court[v[0]]+=cnt;
else if(v.size()==2)
{
court[v[0]]+=idk[v[0]][v[1]];
court[v[1]]+=idk[v[1]][v[0]];
}
else
{
for (int k:v)
court[k]+=bst[k];
}
}
for (int j:bestr[i])
{
for (int c=0;c<3;c++)
for (int c1=0;c1<3;c1++)
{
if (c==c1 || r[j][c]>r[j][c1])
continue;
if (r[j][c]<r[j][c1])
idk[c][c1]++;
else if(c<c1)
idk[c][c1]++;
}
int cor;
for (int c=2;c>=0;c--)
if (r[j][c]==i)
cor=c;
bst[cor]++;
}
cnt+=bestr[i].size();
}
for (int j=0;j<3;j++)
cout<<court[j]<<' ';
cout<<endl;
for (int j=0;j<n;j++)
cout<<wins[j]<<' ';
cout<<endl;
return 0;
}
Compilation message
tenis.cpp: In function 'int main()':
tenis.cpp:32:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int j=0;j<bestr[i].size();j++)
| ~^~~~~~~~~~~~~~~~
tenis.cpp:33:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int k=j+1;k<bestr[i].size();k++)
| ~^~~~~~~~~~~~~~~~
tenis.cpp:93:11: warning: 'cor' may be used uninitialized in this function [-Wmaybe-uninitialized]
93 | bst[cor]++;
| ~~~~~~~^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
26 ms |
3416 KB |
Output is correct |
6 |
Correct |
39 ms |
5204 KB |
Output is correct |
7 |
Correct |
70 ms |
6644 KB |
Output is correct |
8 |
Correct |
69 ms |
8276 KB |
Output is correct |
9 |
Correct |
65 ms |
7884 KB |
Output is correct |
10 |
Correct |
83 ms |
9296 KB |
Output is correct |