제출 #408666

#제출 시각아이디문제언어결과실행 시간메모리
408666mat_vCarnival Tickets (IOI20_tickets)C++14
0 / 100
1 ms332 KiB
#include "tickets.h" #include <bits/stdc++.h> #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i)) #define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i)) #define pii pair<int,int> #define xx first #define yy second #define pb push_back using namespace std; pii mat[1505][1505]; int ans[1505][1505]; int kol[1505]; int ima[1505]; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); ff(i,0,n - 1){ ff(j,0,m - 1){ mat[i + 1][j + 1] = {x[i][j], j+1}; } } ff(i,1,n)sort(mat[i] + 1, mat[i] + m + 1); ff(i,1,n)ff(j,1,m)ans[i][j] = -1; priority_queue<pii> pq; ff(i,1,n){ pq.push({mat[i][m].xx + mat[i][k].xx, i}); } ff(i,1,(n*k)/2){ pii sta = pq.top(); pq.pop(); kol[sta.yy]++; if(kol[sta.yy] < k){ pq.push({mat[sta.yy][k-kol[sta.yy]].xx + mat[sta.yy][m-kol[sta.yy]].xx, sta.yy}); } } ff(i,1,n){ int dole = k - kol[i]; ff(j,1,k){ if(ima[j] < k){ if(kol[i] > 0){ ans[i][mat[i][m-kol[i]+1].yy] = j-1; kol[i]--; ima[j]++; } else{ ans[i][mat[i][dole - 1].yy] = j-1; dole--; } } else{ ans[i][mat[i][dole - 1].yy] = j-1; dole--; } } } vector<vector<int>>answer; ff(i,1,n){ vector<int> row; ff(j,1,m)row.pb(ans[i][j]); } allocate_tickets(answer); return 1; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
tickets.cpp:22:2: note: in expansion of macro 'ff'
   22 |  ff(i,0,n - 1){
      |  ^~
tickets.cpp:4:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
tickets.cpp:23:9: note: in expansion of macro 'ff'
   23 |         ff(j,0,m - 1){
      |         ^~
tickets.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
tickets.cpp:27:2: note: in expansion of macro 'ff'
   27 |  ff(i,1,n)sort(mat[i] + 1, mat[i] + m + 1);
      |  ^~
tickets.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
tickets.cpp:28:5: note: in expansion of macro 'ff'
   28 |     ff(i,1,n)ff(j,1,m)ans[i][j] = -1;
      |     ^~
tickets.cpp:4:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
tickets.cpp:28:14: note: in expansion of macro 'ff'
   28 |     ff(i,1,n)ff(j,1,m)ans[i][j] = -1;
      |              ^~
tickets.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
tickets.cpp:30:5: note: in expansion of macro 'ff'
   30 |     ff(i,1,n){
      |     ^~
tickets.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
tickets.cpp:33:5: note: in expansion of macro 'ff'
   33 |     ff(i,1,(n*k)/2){
      |     ^~
tickets.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
tickets.cpp:41:5: note: in expansion of macro 'ff'
   41 |     ff(i,1,n){
      |     ^~
tickets.cpp:4:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
tickets.cpp:43:9: note: in expansion of macro 'ff'
   43 |         ff(j,1,k){
      |         ^~
tickets.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
tickets.cpp:62:5: note: in expansion of macro 'ff'
   62 |     ff(i,1,n){
      |     ^~
tickets.cpp:4:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
tickets.cpp:64:9: note: in expansion of macro 'ff'
   64 |         ff(j,1,m)row.pb(ans[i][j]);
      |         ^~
#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...