#include <bits/stdc++.h>
#define ll long long
#define loop(i, a, b) for(ll i=a;i<b;i++)
#define pool(i, a, b) for(ll i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 100100
#define par pair<ll, ll>
#define ld long double
#define mod 1000000007
ll per[mn][3], inv[mn][3];
ll cnt[9][3];
void create(ll ind, ll coc){
loop(i, 1, 9){
ll zmgpol=-1;
loop(pol, 0, 3) if(i&(1<<pol) and (zmgpol==-1 or inv[ind][pol]<inv[ind][zmgpol])) zmgpol=pol;
cnt[i][zmgpol]+=coc;
}
}
ll vis[mn];
ll cntpol[3], cntpla[mn];
int main() {
ll n;cin >> n;
loop(pol, 0, 3){
loop(i, 0, n){
sc("%lld", &per[i][pol]);per[i][pol]--;
inv[per[i][pol]][pol]=i;
}
}
loop(i, 0, n) create(i, 1);
ll ost=n;
loop(i, 0, n){
map<ll, ll> sce;
loop(pol, 0, 3) if(!vis[per[i][pol]])sce[per[i][pol]]+=(1<<pol);
fore(v, sce) create(v.fi, -1), --ost, vis[v.fi]=1;
fore(v, sce){
cntpla[v.fi]+=ost;
loop(pol, 0, 3) cntpol[pol]+=cnt[v.se][pol];
}
fore(v, sce) fore(u, sce) if(v.fi<u.fi){
ll kdo=-1, zmgpol=-1;
loop(pol, 0, 3){
if(((1<<pol) & v.se) and (kdo==-1 or inv[u.fi][pol]<inv[kdo][zmgpol])) zmgpol=pol, kdo=u.fi;
if(((1<<pol) & u.se) and (kdo==-1 or inv[v.fi][pol]<inv[kdo][zmgpol])) zmgpol=pol, kdo=v.fi;
}
//cout << v.fi <<u.fi << kdo<<endl;
++cntpol[zmgpol];
++cntpla[(kdo==v.fi) ? u.fi:v.fi];
}
}
loop(i, 0, 3) cout << cntpol[i]<<" ";cout << endl;
loop(i, 0, n) cout << cntpla[i]<<" ";cout<<endl;
}
Compilation message
tenis.cpp: In function 'int main()':
tenis.cpp:3:23: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
3 | #define loop(i, a, b) for(ll i=a;i<b;i++)
| ^~~
tenis.cpp:67:5: note: in expansion of macro 'loop'
67 | loop(i, 0, 3) cout << cntpol[i]<<" ";cout << endl;
| ^~~~
tenis.cpp:67:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
67 | loop(i, 0, 3) cout << cntpol[i]<<" ";cout << endl;
| ^~~~
tenis.cpp:3:23: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
3 | #define loop(i, a, b) for(ll i=a;i<b;i++)
| ^~~
tenis.cpp:68:5: note: in expansion of macro 'loop'
68 | loop(i, 0, n) cout << cntpla[i]<<" ";cout<<endl;
| ^~~~
tenis.cpp:68:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
68 | loop(i, 0, n) cout << cntpla[i]<<" ";cout<<endl;
| ^~~~
tenis.cpp:37:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
37 | sc("%lld", &per[i][pol]);per[i][pol]--;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
30 ms |
3324 KB |
Output is correct |
6 |
Correct |
45 ms |
4716 KB |
Output is correct |
7 |
Correct |
63 ms |
6072 KB |
Output is correct |
8 |
Correct |
101 ms |
7480 KB |
Output is correct |
9 |
Correct |
80 ms |
7404 KB |
Output is correct |
10 |
Partially correct |
79 ms |
7404 KB |
Partially correct |