제출 #516219

#제출 시각아이디문제언어결과실행 시간메모리
516219fcmalkcinGift (IZhO18_nicegift)C++17
0 / 100
735 ms113044 KiB
/*#pragma GCC optimize("Ofast") #pragma GCC optimization("unroll-loops, no-stack-protector") #pragma GCC target("avx,avx2,fma")*/ #include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define ff first #define ss second #define pb push_back #define endl "\n" #define F(i,a,b) for (ll i=a;i<=b;i++) mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); const ll maxn=1e6+40; const ll mod=1000003 ; const ll base=3e18; /// you will be the best but now you just are trash /// goal 2/7 ll a[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("t.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll n, k; cin>> n>> k; set<pll> st; for (int i=1;i<=n;i++) { cin>> a[i]; st.insert(make_pair(a[i],i)); } vector<pair<ll,vector<ll>>> ans; while (st.size()>=k) { auto it=(st.begin()); ll val=(*it).ff; vector<ll> vt; vt.pb((*it).ss); it=st.end(); ll len=k-1; vector<pll> vt1; while (len--) { it--; vt.pb((*it).ss); vt1.pb((*it)); } ans.pb(make_pair(val,vt)); st.erase(st.begin()); for (auto to:vt1) { pll p=to; st.erase(p); if (p.ff>val) { p.ff-=val; st.insert(p); } } } if (st.size()) { cout <<-1; return 0; } cout <<ans.size()<<endl; for (auto p:ans) { cout <<p.ff<<" "; for (auto to:p.ss) cout <<to<<" "; cout <<endl; } }

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

nicegift.cpp: In function 'int main()':
nicegift.cpp:45:21: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   45 |     while (st.size()>=k)
      |            ~~~~~~~~~^~~
nicegift.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nicegift.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...