Submission #705245

#TimeUsernameProblemLanguageResultExecution timeMemory
705245bin9638Scales (IOI15_scales)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define fs first #define sc second #define N 12 #define pb push_back #define ii pair<int,int> int p[N],w[N]; vector<int>g[N]; #ifdef SKY void answer(int W[]) { for(int i=0;i<6;i++)cout<<W[i]<<" ";cout<<endl; } bool SS(const int&u,const int&v) { return w[u]<w[v]; } int getHeaviest(int A, int B, int C) { cout<<"cc\n"; int f[3]={A,B,C}; sort(f,f+3,SS); return f[2]; } int getLightest(int A,int B,int C) { cout<<"cc\n"; int f[3]={A,B,C}; sort(f,f+3,SS); return f[0]; } #endif // SKY struct trip { int A,B,C; }; vector<trip>trip; int bit[N]; bool check() { for(int i=1;i<=6;i++) bit[i]=(1<<i); int deg[N]={}; stack<int>st; for(int i=1;i<=6;i++) for(auto v:g[i]) deg[v]++; for(int i=1;i<=6;i++) if(deg[i]==0) st.push(i); while(!st.empty()) { int u=st.top(); st.pop(); for(auto v:g[u]) { bit[v]|=bit[u]; if(--deg[v]==0) st.push(v); } } int ktr[N]={}; for(int i=1;i<=6;i++) ktr[__builtin_popcount(bit[i])]++; for(int i=1;i<=6;i++) if(ktr[i]!=1) return 0; return 1; } void orderCoins() { #ifdef SKY for(int i=1;i<=6;i++) cin>>p[i],w[p[i]]=i; #endif // SKY srand(time(0)); for(int i=1;i<=6;i++) g[i].clear(); trip.clear(); for(int i=1;i<=6;i++) for(int j=1;j<i;j++) for(int k=1;k<j;k++) trip.pb({i,j,k}); random_shuffle(trip.begin(),trip.end()); for(auto u:trip) { int c=getHeaviest(u.A,u.B,u.C); if(c!=u.A) g[u.A].pb(c); if(c!=u.B) g[u.B].pb(c); if(c!=u.C) g[u.C].pb(c); if(check()) { int kq[6]; for(int i=1;i<=6;i++) kq[__builtin_popcount(bit[i])-1]=i; answer(kq); return; } c=getLightest(u.A,u.B,u.C); if(c!=u.A) g[c].pb(u.A); if(c!=u.B) g[c].pb(u.B); if(c!=u.C) g[c].pb(u.C); if(check()) { int kq[6]; for(int i=1;i<=6;i++) kq[__builtin_popcount(bit[i])-1]=i; answer(kq); return; } } } void init(int q) { while(q--) orderCoins(); } #ifdef SKY int main() { freopen("A.inp","r",stdin); freopen("A.out","w",stdout); // ios::sync_with_stdio(0); // cin.tie(NULL); // cout.tie(NULL); int q; cin>>q; init(q); return 0; } #endif // SKY

Compilation message (stderr)

scales.cpp: In function 'void orderCoins()':
scales.cpp:88:15: warning: conversion from 'time_t' {aka 'long int'} to 'unsigned int' may change value [-Wconversion]
   88 |     srand(time(0));
      |           ~~~~^~~
scales.cpp:99:15: error: 'getHeaviest' was not declared in this scope
   99 |         int c=getHeaviest(u.A,u.B,u.C);
      |               ^~~~~~~~~~~
scales.cpp:111:13: error: 'answer' was not declared in this scope
  111 |             answer(kq);
      |             ^~~~~~
scales.cpp:114:11: error: 'getLightest' was not declared in this scope
  114 |         c=getLightest(u.A,u.B,u.C);
      |           ^~~~~~~~~~~
scales.cpp:126:13: error: 'answer' was not declared in this scope
  126 |             answer(kq);
      |             ^~~~~~