Submission #800275

#TimeUsernameProblemLanguageResultExecution timeMemory
800275becaidoCarnival Tickets (IOI20_tickets)C++17
11 / 100
3 ms596 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> using namespace std; #ifndef WAIMAI #include "tickets.h" #endif #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() {cout << '\n';} template<typename T, typename...U> void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);} #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second #ifdef WAIMAI void allocate_tickets( vector<vector<int>> _x); #endif const int SIZE = 1505; int id[SIZE]; ll find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> ans; ans.resize(n, vector<int>(m, -1)); if (m == 1) { iota(id, id + n, 0); sort(id, id + n, [&](int l, int r) { return x[l][0] < x[r][0]; }); ll sum = 0; FOR (i, 0, n / 2 - 1) sum -= x[id[i]][0]; FOR (i, n / 2, n - 1) sum += x[id[i]][0]; FOR (i, 0, n - 1) ans[i][0] = 0; allocate_tickets(ans); return sum; } } /* in1 2 3 2 0 2 5 1 1 3 out1 7 0 -1 1 -1 1 0 in2 4 2 1 5 9 1 4 3 6 2 7 out2 12 -1 0 0 -1 0 -1 -1 0 */ #ifdef WAIMAI static int n; static int m; static int k; static vector<vector<int>> d; static vector<vector<int>> x; static int called = 0; static void check(bool cond, string message) { if (!cond) { printf("%s\n", message.c_str()); exit(0); } } void allocate_tickets( vector<vector<int>> _d) { check(!called, "allocate_tickets called more than once"); d = _d; check((int)d.size() == n, "allocate_tickets called with parameter of wrong size"); for (int i = 0; i < n; i++) { check((int)d[i].size() == m, "allocate_tickets called with parameter of wrong size"); } called = 1; } int main() { assert(scanf("%d %d %d", &n, &m, &k) == 3); x.resize(n); for (int i = 0; i < n; i++) { x[i].resize(m); for (int j=0; j < m; j++) { assert(scanf("%d", &x[i][j]) == 1); } } fclose(stdin); ll ans = find_maximum(k, x); check(called, "failure to call allocate_tickets"); printf("%lld\n", ans); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (j) printf(" "); printf("%d", d[i][j]); } printf("\n"); } fclose(stdout); return 0; } #endif

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:36:25: warning: control reaches end of non-void function [-Wreturn-type]
   36 |     vector<vector<int>> ans;
      |                         ^~~
#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...