제출 #308635

#제출 시각아이디문제언어결과실행 시간메모리
308635Peti카니발 티켓 (IOI20_tickets)C++14
0 / 100
4 ms640 KiB
#include "tickets.h" #include <iostream> #include <algorithm> #include <vector> using namespace std; void Forgat(vector<vector<pair<int, int>>> &table, int ind, int k, int m, int f){ vector<pair<int, int>> temp(m); for(int i = 0; i < m; i++) { if(i < m-k){ temp[i] = table[ind][i]; continue; } int x = ((i-m+k) + f)%k + m - k; temp[x] = table[ind][i]; } table[ind] = temp; return; } long long find_maximum(int k, vector<vector<int>> table) { int n = (int)table.size(), m = (int)table[0].size(); vector<pair<int, pair<int, int>>> sor; for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) sor.push_back(make_pair(table[i][j], make_pair(i, j))); vector<vector<pair<int, int>>> table2(n, vector<pair<int, int>>(m)); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) table2[i][j] = make_pair(1, j); sort(sor.begin(), sor.end()); for(int i = 0; i < (int)sor.size()/2; i++) table2[sor[i].second.first][sor[i].second.second].first = -1; vector<pair<int, pair<int, pair<int, int>>>> csere; int db = 0; for(int i = 0; i < n; i++) { if(table2[i][m-1].first < 0) continue; int x = 0; for(int j = m-k; j < m; j++) { if(table2[i][j].first == -1) db++; if(table2[i][j].first == 1 && table2[i][x].first == -1) { csere.push_back(make_pair(table[i][j] + table[i][x], make_pair(i, make_pair(x, j)))); x++; } } } int x = 0; while(db < n*k/2) { int a = csere[x].second.first, b = csere[x].second.second.first, c = csere[x].second.second.second; swap(table2[a][b], table2[a][c]); db++; } int forg = 0; for(int i = 0; i < n; i++) { Forgat(table2, i, k, m, forg); for(int j = m-k; j < m; j++) if(table2[i][j].first == -1) forg++; forg %= k; } vector<vector<int>> answer(n, vector<int>(m)); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(j < m-k) answer[i][table2[i][j].second] = -1; else answer[i][table2[i][j].second] = j-m+k; } } int ret = 0; for(int i = 0; i < n; i++) for(int j = m-k; j < m; j++) ret += table2[i][j].first * table[i][table2[i][j].second]; allocate_tickets(answer); return ret; }
#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...