제출 #434237

#제출 시각아이디문제언어결과실행 시간메모리
434237ioi카니발 티켓 (IOI20_tickets)C++14
0 / 100
1 ms332 KiB
#include "tickets.h" #include <vector> #include<bits/stdc++.h> using namespace std ; const int N = 2000 ; vector<int> arr0[N] , arr1[N] ; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size() , m = x[0].size(); vector<vector<int> > ans(n , vector<int> (m , 0)); //allocate_tickets(ans); long long b ; for(int i = 0 ; i < n; i ++){ for(int j = 0 ; j < m ; j ++){ if(x[i][j] == 1)arr1[i].push_back(j); else arr0[i].push_back(j); } } long long ret = 0 ; for(int kk = 0 ; kk < k ;kk++){ // try 0 int sum = 0 ; bool ok = true ; for(int i = 0 ; i < n && ok; i++){ if(arr0[i].size() == 0) ok = false ; } if(ok){ for(int i = 0 ; i < n ; i ++) ans[i][arr0[i].back()] = kk , arr0[i].pop_back() ; continue ; } ok = true ; for(int i = 0 ; i < n && ok ; i ++){ if(arr1[i].size() == 0) ok = false ; } if(ok){ for(int i = 0 ; i < n ; i ++) ans[i][arr1[i].back()] = kk , arr1[i].pop_back(); continue ; } for(int i = 0 ; i < n ; i ++){ if(arr0[i].empty()) sum ++ ; } int add = min(sum , n - sum); ret += add ; add = (add == sum ? 1 : 0); for(int i = 0 ; i < n ; i ++){ if(arr0[i].empty()){ ans[i][arr1[i].back()] = kk ; arr1[i].pop_back(); } else { ans[i][arr0[i].back()] = kk ; arr0[i].pop_back(); } } } allocate_tickets(ans); return ret ; /* 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; */ }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:17:16: warning: unused variable 'b' [-Wunused-variable]
   17 |      long long b ;
      |                ^
#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...