Submission #140101

#TimeUsernameProblemLanguageResultExecution timeMemory
140101SirCenessScales (IOI15_scales)C++14
55.56 / 100
2 ms380 KiB
#include "scales.h" #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define inside sl<=l&&r<=sr #define outside r<sl||sr<l #define orta ((l+r)>>1) #define INF 1000000009 #define mod 1000000007 #define ppair(x); cerr << "(" << x.first << ", " << x.second << ")\n"; #define bas(x) #x << ": " << x << " " #define prarr(x, n); cerr << #x << ": "; for(int qsd = 0; qsd < n; qsd++) cerr << x[qsd] << " "; cerr << "\n"; #define prarrv(x); cerr << #x << ": "; for(int qsd = 0; qsd < (int)x.size(); qsd++) cerr << x[qsd] << " "; cerr << "\n"; using namespace std; typedef long long ll; void init(int T) { } void sil(vector<int>& arr, int val){ for (int i = 0; i < arr.size()-1; i++){ if (arr[i] == val){ swap(arr[i], arr[arr.size()-1]); break; } } arr.pop_back(); } void swap(int a, int b, vector<int>& ar){ if (a == b) return; int s1, s2; for (int i = 0; i < ar.size(); i++){ if (ar[i] == a) s1 = i; if (ar[i] == b) s2 = i; } swap(ar[s1], ar[s2]); } void orderCoins() { /* ... */ int W[] = {1, 2, 3, 4, 5, 6}; vector<int> arr; for (int i = 0; i < 6; i++) arr.pb(i+1); int l1 = getLightest(arr[0], arr[1], arr[2]); swap(l1, arr[0], arr); //prarrv(arr); int l2 = getLightest(arr[3], arr[4], arr[5]); swap(l2, arr[3], arr); swap(arr[1], arr[3], arr); //prarrv(arr); int minn = getLightest(arr[0], arr[1], arr[2]); if (minn == arr[1]){ swap(arr[0], arr[1], arr); swap(arr[2], arr[4], arr); swap(arr[3], arr[5], arr); } //prarrv(arr); int minn2 = getLightest(arr[1], arr[2], arr[3]); swap(minn2, arr[1], arr); //prarrv(arr); int olmaz = getHeaviest(arr[2], arr[3], arr[4]); swap(olmaz, arr[5], arr); int sonmin = getLightest(arr[2], arr[3], arr[4]); swap(sonmin, arr[2], arr); //prarrv(arr); int minnn = getLightest(arr[3], arr[4], arr[5]); swap(arr[3], minnn, arr); int maxxx = getHeaviest(arr[3], arr[4], arr[5]); swap(arr[5], maxxx, arr); for (int i = 0; i < 6; i++) W[i] = arr[i]; answer(W); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:18:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
scales.cpp: In function 'void sil(std::vector<int>&, int)':
scales.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < arr.size()-1; i++){
                  ~~^~~~~~~~~~~~~~
scales.cpp: In function 'void swap(int, int, std::vector<int>&)':
scales.cpp:35:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < ar.size(); i++){
                  ~~^~~~~~~~~~~
scales.cpp:39:20: warning: 's2' may be used uninitialized in this function [-Wmaybe-uninitialized]
  swap(ar[s1], ar[s2]);
                    ^
scales.cpp:39:12: warning: 's1' may be used uninitialized in this function [-Wmaybe-uninitialized]
  swap(ar[s1], ar[s2]);
            ^
#Verdict Execution timeMemoryGrader output
Fetching results...