제출 #1052816

#제출 시각아이디문제언어결과실행 시간메모리
1052816pcc카니발 티켓 (IOI20_tickets)C++17
100 / 100
511 ms76168 KiB
#include "tickets.h" #include <vector> #include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,popcnt,sse4") using namespace std; #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second /* int n = x.size(); int m = x[0].size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row(m); for (int j = 0; j < m; j++) { if (j < k) { row[j] = j; } else { row[j] = -1; } } answer.push_back(row); } allocate_tickets(answer); return 1; */ const ll inf = 1e18; const int mxn = 2022; vector<vector<int>> ansv; int len[mxn]; long long find_maximum(int k, std::vector<std::vector<int>> x) { int N = x.size(); int M = x[0].size(); int K = k; ll sum = 0; for(int i = 0;i<N;i++){ for(int j = 0;j<K;j++){ sum -= x[i][j]; } len[i] = K; } priority_queue<pll,vector<pll>,less<pll>> pq; for(int i = 0;i<N;i++){ pq.push(pll(x[i].end()[-1]+x[i][K-1],i)); } for(int i = 0;i<N*K/2;i++){ auto [val,pos] = pq.top(); pq.pop(); sum += val; len[pos]--; ll p = len[pos]; if(p)pq.push(pll(x[pos].end()[-K+p-1]+x[pos][p-1],pos)); } ansv = vector<vector<int>>(N,vector<int>(M,-1)); int C = 0; for(int i = 0;i<N;i++){ for(int j = 0;j<len[i];j++){ ansv[i][j] = C;C = (C+1)%K; } } for(int i = 0;i<N;i++){ set<int> st; for(int j = 0;j<K;j++)st.insert(j); for(int j = 0;j<M;j++){ if(ansv[i][j] != -1)st.erase(ansv[i][j]); } assert(st.size() == K-len[i]); for(int j = 0;j<K-len[i];j++){ ansv[i].end()[-1-j] = *st.begin(); st.erase(st.begin()); } } allocate_tickets(ansv); return sum; }

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

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from tickets.cpp:3:
tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:80:20: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   80 |   assert(st.size() == K-len[i]);
      |          ~~~~~~~~~~^~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...