Submission #1051483

# Submission time Handle Problem Language Result Execution time Memory
1051483 2024-08-10T07:22:28 Z pcc Carnival Tickets (IOI20_tickets) C++17
11 / 100
3000 ms 98980 KB
#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 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 int mxn = 2022;

vector<vector<int>> ansv;
vector<int> choose[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;
	ansv = vector<vector<int>>(N,vector<int>(M,-1));

	{
		vector<pair<int,pii>> v;
		for(int i = 0;i<N;i++){
			for(int j = 0;j<M;j++){
				v.push_back(make_pair(x[i][j],pii(i,j)));
			}
		}
		sort(v.rbegin(),v.rend());
		for(int i = 0;i<N*M/2;i++){
			int r = v[i].sc.fs,c = v[i].sc.sc;
			choose[r].push_back(c);
		}
	}

	ll ans = 0;
	int C = 0;
	for(int i = 0;i<N;i++){
		vector<pii> v;
		for(auto &j:choose[i]){
			ansv[i][j] = C;
			C = (C+1)%K;
		}
	}

	cerr<<"DEBUG: "<<endl;
	for(int i = 0;i<N;i++){
		for(int j =0;j<M;j++)cerr<<ansv[i][j]<<' ';cerr<<endl;
	}cerr<<endl;

	for(int i = 0;i<N;i++){
		set<int> st;
		for(int j = 0;j<M;j++)st.insert(j);
		for(int j = 0;j<M;j++){
			if(ansv[i][j] >= 0)st.erase(ansv[i][j]),ans += x[i][j];
			else ans -= x[i][j];
		}
		for(int j = 0;j<M;j++){
			if(ansv[i][j]>=00)continue;
			ansv[i][j] = *st.begin();
			st.erase(st.begin());
		}
	}
	allocate_tickets(ansv);
	return ans;
}

Compilation message

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:70:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   70 |   for(int j =0;j<M;j++)cerr<<ansv[i][j]<<' ';cerr<<endl;
      |   ^~~
tickets.cpp:70:46: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   70 |   for(int j =0;j<M;j++)cerr<<ansv[i][j]<<' ';cerr<<endl;
      |                                              ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 4 ms 772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Ticket 0 of color 1 is played on invalid day 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Ticket 0 of color 2 is played on invalid day 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 484 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 12 ms 604 KB Output is correct
5 Correct 204 ms 4052 KB Output is correct
6 Correct 28 ms 1056 KB Output is correct
7 Correct 29 ms 1116 KB Output is correct
8 Execution timed out 3040 ms 98980 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 12 ms 800 KB Ticket 0 of color 0 is played on invalid day 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 12 ms 800 KB Ticket 0 of color 0 is played on invalid day 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 4 ms 772 KB Output is correct
7 Incorrect 1 ms 348 KB Ticket 0 of color 1 is played on invalid day 1
8 Halted 0 ms 0 KB -