제출 #604358

#제출 시각아이디문제언어결과실행 시간메모리
6043588e7저울 (IOI15_scales)C++17
71.43 / 100
1 ms272 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r){ while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 100005 #define pii pair<int, int> #define ff first #define ss second #include "scales.h" void init(int T) { /* ... */ srand(time(NULL)); } void orderCoins() { int n = 3; int ini[6] = {1, 2, 3, 4, 5, 6}; random_shuffle(ini, ini + 6); int a[3] = {ini[0], ini[1], ini[2]}, b[3] = {ini[3], ini[4], ini[5]}; int ret[6]; int ind = find(a, a + n, getLightest(a[0], a[1], a[2])) - a; swap(a[ind], a[0]); ind = find(b, b + n, getLightest(b[0], b[1], b[2])) - b; swap(b[ind], b[0]); //a[0] < a[1], a[2], b[0] < b[1], b[2]; int tmp = getHeaviest(a[0], b[1], b[2]); if (tmp == a[0]) { ind = find(b, b + n, getHeaviest(b[0], b[1], b[2])) - b; swap(b[ind], b[2]); ind = find(a, a + n, getHeaviest(a[0], a[1], a[2])) - a; swap(a[ind], a[2]); int r[6] = {b[0], b[1], b[2], a[0], a[1], a[2]}; answer(r); return; } else { if (tmp == b[1]) swap(b[1], b[2]); } tmp = getHeaviest(b[0], a[1], a[2]); if (tmp == b[0]) { ind = find(b, b + n, getHeaviest(b[0], b[1], b[2])) - b; swap(b[ind], b[2]); ind = find(a, a + n, getHeaviest(a[0], a[1], a[2])) - a; swap(a[ind], a[2]); int r[6] = {a[0], a[1], a[2], b[0], b[1], b[2]}; answer(r); return; } else { if (tmp == a[1]) swap(a[1], a[2]); } int pos[3] = {0, 0, 0}; ind = getNextLightest(a[0], a[1], a[2], b[1]); vector<int> check; if (ind == a[0]) { if (getHeaviest(a[0], a[2], b[1]) == b[1]) { pos[1] = 3; pos[2] = 3; check.push_back(0); } else { pos[0] = 0; pos[1] = 0; check.push_back(2); } } else { if (ind == a[1]) pos[1] = 1; else pos[1] = 2; check.push_back(0), check.push_back(2); } for (int i:check) { ind = getNextLightest(a[0], a[1], a[2], b[i]); if (ind == a[1]) { pos[i] = 1; } else if (ind == a[2]) { pos[i] = 2; } else { if (i == 0) pos[i] = 0; else if (i == 2) pos[i] = 3; } } ind = 0; int cur = 0; for (int i = 0;i < 3;i++) { while (ind < 3 && pos[ind] <= i) ret[cur++] = b[ind++]; ret[cur++] = a[i]; } while (ind < 3) ret[cur++] = b[ind++]; answer(ret); }

컴파일 시 표준 에러 (stderr) 메시지

scales.cpp: In function 'void init(int)':
scales.cpp:24:12: warning: conversion from 'time_t' {aka 'long int'} to 'unsigned int' may change value [-Wconversion]
   24 |  srand(time(NULL));
      |        ~~~~^~~~~~
scales.cpp:22:15: warning: unused parameter 'T' [-Wunused-parameter]
   22 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:34:58: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   34 |  int ind = find(a, a + n, getLightest(a[0], a[1], a[2])) - a;
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp:37:54: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   37 |  ind = find(b, b + n, getLightest(b[0], b[1], b[2])) - b;
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp:43:55: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   43 |   ind = find(b, b + n, getHeaviest(b[0], b[1], b[2])) - b;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp:45:55: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   45 |   ind = find(a, a + n, getHeaviest(a[0], a[1], a[2])) - a;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp:56:55: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   56 |   ind = find(b, b + n, getHeaviest(b[0], b[1], b[2])) - b;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp:58:55: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   58 |   ind = find(a, a + n, getHeaviest(a[0], a[1], a[2])) - a;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...