# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
820160 |
2023-08-10T21:34:00 Z |
tolbi |
Scales (IOI15_scales) |
C++17 |
|
1 ms |
308 KB |
#pragma optimize("Bismillahirrahmanirrahim");
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
//Sani buyuk Osman Pasa Plevneden cikmam diyor
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
template<typename T> istream& operator>>(istream& is, vector<T> &v){for (auto &it : v) is>>it;return is;}
template<typename T, size_t Y> istream& operator>>(istream& is, array<T,Y> &v){for (auto &it : v) is>>it;return is;}
template<typename T> ostream& operator<<(ostream& os, vector<T> &v){for (auto &it : v) os<<it<<" ";return os;}
template<typename T, size_t Y> ostream& operator<<(ostream& os, array<T,Y> &v){for (auto &it : v) os<<it<<" ";return os;}
template<typename X, typename Y> istream& operator>>(istream& is, pair<X,Y> &pr){return is<<pr.first<<" "<<pr.second;}
template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> &pr){return os>>pr.first>>pr.second;}
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define vint(x) vector<int> x
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(), x.end())
#define sortrarr(x) sort(x.rbegin(), x.rend())
#define rev(x) reverse(x.begin(), x.end())
#define endl '\n'
#define tol(bi) (1LL<<((int)(bi)))
typedef long long ll;
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#include "scales.h"
void init(int T) {
/* ahmet23 orz... */
}
int getMedian(int A, int B, int C);
int getHeaviest(int A, int B, int C);
int getLightest(int A, int B, int C);
int getNextLightest(int A, int B, int C, int D);
void orderCoins() {
/* ... */
int W[] = {1, 2, 3, 4, 5, 6};
for (int i = 5; i >= 0; i--){
swap(W[i],W[ayahya()%(i+1)]);
}
int ans = getLightest(W[0],W[1],W[2]);
if (ans==W[1]){
swap(W[1],W[0]);
}
else if (ans==W[2]){
swap(W[0],W[2]);
}
ans=getHeaviest(W[1],W[2],W[3]);
if (ans==W[1]){
swap(W[1],W[3]);
swap(W[1],W[2]);
}
else if (ans==W[2]){
swap(W[2],W[3]);
}
ans=getMedian(W[0],W[1],W[2]);
if (ans==W[0]){
swap(W[1],W[2]);
swap(W[0],W[1]);
}
else if (ans==W[2]){
swap(W[1],W[2]);
}
//0,1,2,3 sortlu
ans=getLightest(W[3],W[4],W[5]);
if (ayahya()%2) swap(W[4],W[5]);
if (ans==W[3]){
ans=getHeaviest(W[3],W[4],W[5]);
if (ans==W[4])swap(W[4], W[5]);
//5 moves
answer(W);return /*W*/;
}
//ahb
if (ans==W[5]) swap(W[4],W[5]);
ans=getMedian(W[2],W[3],W[5]);
if (ans==W[2]){
swap(W[2],W[4]);
swap(W[3],W[5]);
ans=getMedian(W[0],W[1],W[2]);
if (ans==W[2]){
swap(W[1],W[2]);
ans=getHeaviest(W[0],W[2],W[3]);
if (ans==W[2]){
swap(W[2],W[3]);
//7 moves
answer(W);return /*W*/;
}
}
else if (ans==W[0]){
swap(W[1],W[2]);
swap(W[0],W[1]);
ans=getMedian(W[1],W[2],W[3]);
if (ans==W[1]){
swap(W[2],W[3]);
swap(W[1],W[2]);
}
if (ans==W[3]){
swap(W[2],W[3]);
}
//7 moves
answer(W);return /*W*/;
}
else {
//6 moves
answer(W);return /*W*/;
}
}
else if (ans==W[5]){
/*
swap(W[3],W[4]);
swap(W[4],W[5]);
swap(W[3],W[4]);
without loss of generality
*/
swap(W[3],W[5]);
}
//[0,3] sorted. insert 4 between them.
//0 1 2 3 4
ans=getMedian(W[2],W[3],W[4]);
if (ans==W[3]){
//6 moves
answer(W);return /*W*/;
}
else if (ans==W[4]){
swap(W[3],W[4]);
//6 moves
answer(W);return /*W*/;
}
//0 1 4
swap(W[3],W[4]);
swap(W[2],W[3]);
ans=getMedian(W[0],W[1],W[2]);
if (ans==W[0]){
swap(W[1],W[2]);
swap(W[0],W[1]);
}
else if (ans==W[2]){
swap(W[1],W[2]);
}
//6 moves
answer(W);return /*W*/;
}
Compilation message
scales.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
1 | #pragma optimize("Bismillahirrahmanirrahim");
|
scales.cpp: In function 'void init(int)':
scales.cpp:35:19: warning: unused parameter 'T' [-Wunused-parameter]
35 | void init(int T) {
| ~~~~^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
2 |
Partially correct |
1 ms |
308 KB |
Output is partially correct |
3 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
4 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
5 |
Partially correct |
1 ms |
308 KB |
Output is partially correct |
6 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
7 |
Partially correct |
1 ms |
304 KB |
Output is partially correct |
8 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
9 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
10 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
11 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
12 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
13 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
14 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
15 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
16 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
17 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
18 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
19 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
20 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
21 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
22 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
23 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
24 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
25 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
26 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
27 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
28 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
29 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
30 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
31 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
32 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
33 |
Partially correct |
0 ms |
304 KB |
Output is partially correct |
34 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
35 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
36 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
37 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
38 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
39 |
Partially correct |
0 ms |
300 KB |
Output is partially correct |
40 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |