Submission #778057

#TimeUsernameProblemLanguageResultExecution timeMemory
778057Jarif_RahmanScales (IOI15_scales)C++17
0 / 100
1 ms212 KiB
#include "scales.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int w[6]; void init(int T){ for(int i = 0; i < 6; i++) w[i] = i+1; } template<typename it, typename t> void merge_sort(it l, it r, t && comp){ int n = r-l; if(n <= 1) return; int md = n/2; merge_sort(l, l+md, comp); merge_sort(l+md, r, comp); typename remove_reference<decltype(*l)>::type* sth = new typename remove_reference<decltype(*l)>::type[n]; for(int i = 0; i < n; i++) sth[i] = *(l+i); merge(sth, sth+md, sth+md, sth+n, l, comp); delete[] sth; } void orderCoins(){ /* determine heaviest */{ int a = getHeaviest(1, 2, 3), b = getHeaviest(4, 5, 6); int c = 1; if(c == a) c = 2; int d = getHeaviest(a, b, c); if(d != 6) swap(w[d-1], w[5]); } merge_sort(w, w+5, [&](int a, int b){ return getLightest(a, b, w[5]) == a; }); answer(w); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:13:15: warning: unused parameter 'T' [-Wunused-parameter]
   13 | void init(int T){
      |           ~~~~^
scales.cpp: In instantiation of 'void merge_sort(it, it, t&&) [with it = int*; t = orderCoins()::<lambda(int, int)>]':
scales.cpp:42:6:   required from here
scales.cpp:19:14: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   19 |     int n = r-l;
      |             ~^~
scales.cpp: In instantiation of 'void merge_sort(it, it, t&&) [with it = int*; t = orderCoins()::<lambda(int, int)>&]':
scales.cpp:22:15:   required from 'void merge_sort(it, it, t&&) [with it = int*; t = orderCoins()::<lambda(int, int)>]'
scales.cpp:42:6:   required from here
scales.cpp:19:14: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
#Verdict Execution timeMemoryGrader output
Fetching results...