제출 #761376

#제출 시각아이디문제언어결과실행 시간메모리
761376Red_Inside저울 (IOI15_scales)C++17
71.43 / 100
97 ms360 KiB
#include "scales.h" #include <bits/stdc++.h> //#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops") #define ll long long #define f first #define s second #define pb push_back #define mp make_pair #define o cout<<"BUG"<<endl; #define FOR(i, j, n) for(int j = i; j < n; ++j) #define forn(i, j, n) for(int j = i; j <= n; ++j) #define nfor(i, j, n) for(int j = n; j >= i; --j) #define all(v) v.begin(), v.end() #define ld long double #define ull unsigned long long using namespace std; const int maxn=188500+10,LOG=17,mod=1e9+7; int block = 200, timer = 0; const double eps = 1e-9; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define bt(i) (1 << (i)) //#define int ll const int inf=2e9; #define y1 yy #define pii pair <int, int> vector <int> perms[720]; void init(int T) { vector <int> vec; forn(1, i, 6) { vec.pb(i); } int cnt = 0; do { perms[cnt] = vec; cnt++; }while(next_permutation(all(vec))); return; } int check(int num, int a, int b, int c, int res, int ty) { //types //1 - min //2 - mid //3 - max int pa, pb, pc; FOR(0, i, perms[num].size()) { if(perms[num][i] == a) pa = i; if(perms[num][i] == b) pb = i; if(perms[num][i] == c) pc = i; } int TrueRes; int mn = min({pa, pb, pc}); int mx = max({pa, pb, pc}); if(ty == 1) { if(pa == mn) TrueRes = 1; if(pb == mn) TrueRes = 2; if(pc == mn) TrueRes = 3; } if(ty == 3) { if(pa == mx) TrueRes = 1; if(pb == mx) TrueRes = 2; if(pc == mx) TrueRes = 3; } if(ty == 2) { if(pa != mn && pa != mx) TrueRes = 1; if(pb != mn && pb != mx) TrueRes = 2; if(pc != mn && pc != mx) TrueRes = 3; } return (TrueRes == res); } int check4(int num, int a, int b, int c, int d, int res) { int pd; int pa, pb, pc; FOR(0, i, perms[num].size()) { if(perms[num][i] == a) pa = i; if(perms[num][i] == b) pb = i; if(perms[num][i] == c) pc = i; if(perms[num][i] == d) pd = i; } int TrueRes = -1; if(max({pa, pb, pc}) < pd) { if(min({pa, pb, pc}) == pa) TrueRes = 1; if(min({pa, pb, pc}) == pb) TrueRes = 2; if(min({pa, pb, pc}) == pc) TrueRes = 3; } else { FOR(pd+1, i, perms[num].size()) { if(i == pa) { TrueRes = 1; break; } if(i == pb) { TrueRes = 2; break; } if(i == pc) { TrueRes = 3; break; } } } return (TrueRes == res); } void orderCoins() { vector <int> can; forn(0, i, 719) can.pb(i); while(can.size() > 1) { /*if(can.size() < 10) { cout << " POSSIBLE\n"; for(auto i : can) { forn(0, j, 5) cout << perms[i][j] << " "; cout << "\n"; } }*/ int tekans = inf; vector <int> vec; forn(1, ty, 3) { forn(1, i, 6) { forn(i + 1, j, 6) { forn(j + 1, k, 6) { int Res = -1; forn(1, res, 3) { int cnt = 0; for(auto per : can) { if(check(per, i, j, k, res, ty)) cnt++; } Res = max(Res, cnt); } if(Res < tekans) { tekans = Res; vec = {ty, i, j, k}; } } } } } forn(1, i, 6) { forn(i + 1, j, 6) { forn(j + 1, k, 6) { forn(1, it, 6) { if(it == i || it == j || it == k) continue; int Res = 0; forn(1, res, 3) { int cnt = 0; for(auto per : can) { if(check4(per, i, j, k, it, res)) cnt++; } Res = max(Res, cnt); } if(Res < tekans) { tekans = Res; vec = {4, i, j, k, it}; } } } } } int res; if(vec[0] == 4) { res = getNextLightest(vec[1], vec[2], vec[3], vec[4]); if(res == vec[1]) res = 1; if(res == vec[2]) res = 2; if(res == vec[3]) res = 3; vector <int> nw; for(auto i : can) { if(check4(i, vec[1], vec[2], vec[3], vec[4], res)) nw.pb(i); } can = nw; } else { if(vec[0] == 1) { res = getLightest(vec[1], vec[2], vec[3]); if(res == vec[1]) res = 1; if(res == vec[2]) res = 2; if(res == vec[3]) res = 3; } if(vec[0] == 2) { res = getMedian(vec[1], vec[2], vec[3]); if(res == vec[1]) res = 1; if(res == vec[2]) res = 2; if(res == vec[3]) res = 3; } if(vec[0] == 3) { res = getHeaviest(vec[1], vec[2], vec[3]); if(res == vec[1]) res = 1; if(res == vec[2]) res = 2; if(res == vec[3]) res = 3; } vector <int> nw; for(auto i : can) { if(check(i, vec[1], vec[2], vec[3], res, vec[0])) nw.pb(i); } can = nw; } } int W[6]; FOR(0, i, 6) W[i] = perms[can[0]][i]; answer(W); }

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

scales.cpp: In function 'void init(int)':
scales.cpp:35:15: warning: unused parameter 'T' [-Wunused-parameter]
   35 | void init(int T)
      |           ~~~~^
scales.cpp: In function 'int check(int, int, int, int, int, int)':
scales.cpp:13:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 | #define FOR(i, j, n) for(int j = i; j < n; ++j)
......
   58 |  FOR(0, i, perms[num].size())
      |         ~~~~~~~~~~~~~~~~~~~~           
scales.cpp:58:2: note: in expansion of macro 'FOR'
   58 |  FOR(0, i, perms[num].size())
      |  ^~~
scales.cpp: In function 'int check4(int, int, int, int, int, int)':
scales.cpp:13:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 | #define FOR(i, j, n) for(int j = i; j < n; ++j)
......
   92 |  FOR(0, i, perms[num].size())
      |         ~~~~~~~~~~~~~~~~~~~~           
scales.cpp:92:2: note: in expansion of macro 'FOR'
   92 |  FOR(0, i, perms[num].size())
      |  ^~~
scales.cpp:13:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 | #define FOR(i, j, n) for(int j = i; j < n; ++j)
......
  108 |   FOR(pd+1, i, perms[num].size())
      |             ~~~~~~~~~~~~~~~~~~~~       
scales.cpp:108:3: note: in expansion of macro 'FOR'
  108 |   FOR(pd+1, i, perms[num].size())
      |   ^~~
scales.cpp: In function 'int check(int, int, int, int, int, int)':
scales.cpp:77:3: warning: 'pc' may be used uninitialized in this function [-Wmaybe-uninitialized]
   77 |   if(pc == mx) TrueRes = 3;
      |   ^~
scales.cpp:76:3: warning: 'push_back' may be used uninitialized in this function [-Wmaybe-uninitialized]
   76 |   if(pb == mx) TrueRes = 2;
      |   ^~
scales.cpp:57:6: warning: 'pa' may be used uninitialized in this function [-Wmaybe-uninitialized]
   57 |  int pa, pb, pc;
      |      ^~
scales.cpp: In function 'int check4(int, int, int, int, int, int)':
scales.cpp:91:14: warning: 'pc' may be used uninitialized in this function [-Wmaybe-uninitialized]
   91 |  int pa, pb, pc;
      |              ^~
scales.cpp:10:12: warning: 'push_back' may be used uninitialized in this function [-Wmaybe-uninitialized]
   10 | #define pb push_back
      |            ^~~~~~~~~
scales.cpp:10:12: note: 'push_back' was declared here
   10 | #define pb push_back
      |            ^~~~~~~~~
scales.cpp:91:10: note: in expansion of macro 'pb'
   91 |  int pa, pb, pc;
      |          ^~
scales.cpp:91:6: warning: 'pa' may be used uninitialized in this function [-Wmaybe-uninitialized]
   91 |  int pa, pb, pc;
      |      ^~
scales.cpp:100:2: warning: 'pd' may be used uninitialized in this function [-Wmaybe-uninitialized]
  100 |  if(max({pa, pb, pc}) < pd)
      |  ^~
scales.cpp: In function 'void orderCoins()':
scales.cpp:242:13: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
  242 |     if(check(i, vec[1], vec[2], vec[3], res, vec[0])) nw.pb(i);
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...