#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
const int MAXN = 1e5+1;
int a[3][MAXN],ans[MAXN],cr[3];
int w,l;
int main()
{
owo
int n;
cin>>n;
for(int j=0;j<3;j++){
for(int i=0;i<n;i++){
int c;
cin>>c;
a[j][c-1]=i;
}
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
w = min(a[0][i],a[0][j]);
l = max(a[0][i],a[0][j]);
int c = 0;
for(int k=1;k<3;k++){
int wn = min(a[k][i],a[k][j]);
int ln = max(a[k][i],a[k][j]);
//cout<<wn<<" "<<ln<<'\n';
if(wn < w){
w = wn;
l = ln;
c = k;
}
else if(w== wn){
if(ln < l){
l = ln;
c = k;
}
}
}
//cout<<i<<" "<<j<<" "<<c<<'\n';
cr[c]++;
if(a[c][i] > a[c][j])ans[j]++;
else ans[i]++;
}
}
cout<<cr[0]<<" "<<cr[1]<<" "<<cr[2]<<'\n';
for(int i=0;i<n;i++)cout<<ans[i]<<" ";
cout<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
80 ms |
404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
80 ms |
404 KB |
Output is correct |
5 |
Execution timed out |
1080 ms |
1612 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |