# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
368249 |
2021-02-19T20:41:47 Z |
Vimmer |
Tenis (COCI20_tenis) |
C++14 |
|
1 ms |
492 KB |
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
#define N 100501
#define NN 1000500
#define PB push_back
#define M ll(1e9 + 7)
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define _ << " " <<
#define pri(x) cout << x << endl
#define endl '\n'
#define F first
#define S second
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef short int si;
typedef long double ld;
//typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int pos[3][N], ans[N], kol[3], skok[4][3], X, Y;
bool cmpr(int l, int r)
{
int L, R;
if (pos[l][X] > pos[l][Y])
L = pos[l][X];
else L = pos[l][Y];
if (pos[r][X] > pos[r][Y])
R = pos[r][X];
else R = pos[r][Y];
if (L == R) return l < r;
return L < R;
}
int get(int x)
{
return min(pos[0][x], min(pos[1][x], pos[2][x]));
}
bool cmp(int l, int r)
{
return get(l) <= get(r);
}
int calc(int i, int j)
{
X = i;
Y = j;
multiset <int> se; se.clear();
for (int t = 0; t < 3; t++)
{
if (pos[t][i] > pos[t][j])
se.insert(pos[t][j]);
else se.insert(pos[t][i]);
}
vector <int> who; who.clear();
int x = *se.begin();
for (int t = 0; t < 3; t++)
{
if (pos[t][i] == x && pos[t][i] < pos[t][j])
{
who.PB(t);
}
if (pos[t][j] == x && pos[t][j] < pos[t][i])
{
who.PB(t);
}
}
sort(all(who), cmpr);
int t = who[0];
// kol[t]++;
if (pos[t][i] > pos[t][j])
ans[j]++;
else ans[i]++;
}
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen("1.in", "r", stdin);
//
// freopen("pixels.in", "r", stdin);
// freopen("pixels.out", "w", stdout);
int n;
cin >> n;
for (int i = 0; i < 3; i++)
for (int j = 0; j < n; j++)
{
int x;
cin >> x;
x--;
pos[i][x] = j;
}
vector <int> vr; vr.clear();
for (int i = 0; i < n; i++)
vr.PB(i);
sort(all(vr), cmp);
for (int i = 0; i < sz(vr); i++)
{
int u = i;
while (u < sz(vr) && get(vr[i]) == get(vr[u]))
u++;
int l = i, r = u;
if (l + 1 == r)
{
ans[vr[l]] += n - r;
}
else if (l + 2 == r)
{
ans[vr[l]] = ans[vr[l + 1]] = n - r;
calc(vr[l], vr[l + 1]);
}
else
{
ans[vr[l]] = ans[vr[l + 2]] = ans[vr[l + 1]] = n - r;
calc(vr[l], vr[l + 1]);
calc(vr[l], vr[l + 2]);
calc(vr[l + 1], vr[l + 2]);
}
i = u - 1;
}
for (int i = 0; i < 3; i++) cout << kol[i] << " ";
cout << endl;
for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
Compilation message
tenis.cpp: In function 'int calc(int, int)':
tenis.cpp:99:1: warning: no return statement in function returning non-void [-Wreturn-type]
99 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |