QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#218341#7185. Poor Studentsucup-team1055Compile Error//C++143.0kb2023-10-18 03:18:312023-10-18 03:18:32

Judging History

你现在查看的是最新测评结果

  • [2023-10-18 03:18:32]
  • 评测
  • [2023-10-18 03:18:31]
  • 提交

answer

#include <bits/stdc++.h>

#define rep(i,s,n) for(int i = int(s); i < int(n); i++)
#define rrep(i,s,n) for(int i = int(n) - 1; i >= int(s); i--)
#define all(v) (v).begin(), (v).end()

using ll = long long;
using ull = unsigned long long;
using ld = long double;

template<class T>
bool chmin(T &a, T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

template<class T>
bool chmax(T &a, T b) {
    if(a >= b) return false;
    a = b;
    return true;
}

using namespace std;
int main(){
	int n, k; cin >> n >> k;

	vector c(n, vector<int>(k));
	rep(i,0,n){
		rep(j,0,k){
			cin >> c[i][j];
		}
	}

	// cap of EXAM -> DST
	vector<int> a(k);
	rep(i,0,k){
		cin >> a[i];
	}
	
	vector<set<pair<ll,int>>> alive_cost(k);

	// cost of EXAM i -> EXAM j
	vector dead_cost(k, vector<set<pair<ll,int>>>(k));
	rep(i,0,k){
		rep(j,0,n){
			alive_cost[i].insert(pair(c[j][i], j));
		}
	}

	ll ans = 0;

	rep(i,0,n){
		ll tar = 1e18;
		int fore_student = -1;
		int back_student = -1;
		int fore_exam = -1;
		int inst_exam = -1;
		rep(j,0,k){
			if (a[j] > 0){
				// SOLO
				auto itr = alive_cost[j].begin();
				if (chmin(tar, itr->first)){
					fore_student = itr->second;
					back_student = -1;
					fore_exam = j;
					inst_exam = -1;
				}
			}else{
				// DUAL
				auto itr = alive_cost[j].begin();
				rep(l,0,k){
					if (a[l] == 0) continue;
					if (j == l) continue;
					if (dead_cost[j][l].empty()) continue;
					auto itr2 = dead_cost[j][l].begin();
					if (chmin(tar, itr->first + itr2->first)){
						fore_student = itr->second;
						back_student = itr2->second;
						fore_exam = j;
						inst_exam = l;
					}
				}
			}
		}
		if (back_student == -1){
			assert(fore_student != -1);
			a[fore_exam] -= 1;

			// DEL ALIVE COST : fore_student
			rep(j,0,k){
				alive_cost[j].erase(pair(c[fore_student][j], fore_student));
			}

			// INS DEAD LIST [fore_exam] -> [j] : fore_student
			rep(j,0,k){
				if (j == fore_exam) continue;
				dead_cost[fore_exam][j].insert(
					pair(- c[fore_student][fore_exam] + c[fore_student][j], fore_student)
				);
			}
		}else{
			a[inst_exam] -= 1;

			// DEL DEAD LIST [fore_exam] -> [j] : back_student
			rep(j,0,k){
				if (j == fore_exam) continue;
				dead_cost[fore_exam][j].erase(
					pair(- c[back_student][fore_exam] + c[back_student][j], back_student)
				);
			}

			// INS DEAD LIST [inst_exam] -> [j] : back_student
			rep(j,0,k){
				if (j == inst_exam) continue;
				dead_cost[inst_exam][j].insert(
					pair(- c[back_student][inst_exam] + c[back_student][j], back_student)
				);
			}

			// DEL ALIVE COST : fore_student
			rep(j,0,k){
				alive_cost[j].erase(pair(c[fore_student][j], fore_student));
			}

			// INS DEAD LIST [fore_exam] -> [j] : fore_student
			rep(j,0,k){
				if (j == fore_exam) continue;
				dead_cost[fore_exam][j].insert(
					pair(- c[fore_student][fore_exam] + c[fore_student][j], fore_student)
				);
			}
		}

		ans += tar;

		//cout << ans << '\n';
	}

	cout << ans << '\n';
}

Details

answer.code: In function ‘int main()’:
answer.code:29:16: error: missing template arguments before ‘c’
   29 |         vector c(n, vector<int>(k));
      |                ^
answer.code:32:32: error: ‘c’ was not declared in this scope
   32 |                         cin >> c[i][j];
      |                                ^
answer.code:45:16: error: missing template arguments before ‘dead_cost’
   45 |         vector dead_cost(k, vector<set<pair<ll,int>>>(k));
      |                ^~~~~~~~~
answer.code:48:50: error: missing template arguments before ‘(’ token
   48 |                         alive_cost[i].insert(pair(c[j][i], j));
      |                                                  ^
answer.code:48:51: error: ‘c’ was not declared in this scope
   48 |                         alive_cost[i].insert(pair(c[j][i], j));
      |                                                   ^
answer.code:76:45: error: ‘dead_cost’ was not declared in this scope
   76 |                                         if (dead_cost[j][l].empty()) continue;
      |                                             ^~~~~~~~~
answer.code:77:53: error: ‘dead_cost’ was not declared in this scope
   77 |                                         auto itr2 = dead_cost[j][l].begin();
      |                                                     ^~~~~~~~~
answer.code:93:57: error: missing template arguments before ‘(’ token
   93 |                                 alive_cost[j].erase(pair(c[fore_student][j], fore_student));
      |                                                         ^
answer.code:93:58: error: ‘c’ was not declared in this scope
   93 |                                 alive_cost[j].erase(pair(c[fore_student][j], fore_student));
      |                                                          ^
answer.code:99:33: error: ‘dead_cost’ was not declared in this scope
   99 |                                 dead_cost[fore_exam][j].insert(
      |                                 ^~~~~~~~~
answer.code:100:45: error: missing template arguments before ‘(’ token
  100 |                                         pair(- c[fore_student][fore_exam] + c[fore_student][j], fore_student)
      |                                             ^
answer.code:100:48: error: ‘c’ was not declared in this scope
  100 |                                         pair(- c[fore_student][fore_exam] + c[fore_student][j], fore_student)
      |                                                ^
answer.code:109:33: error: ‘dead_cost’ was not declared in this scope
  109 |                                 dead_cost[fore_exam][j].erase(
      |                                 ^~~~~~~~~
answer.code:110:45: error: missing template arguments before ‘(’ token
  110 |                                         pair(- c[back_student][fore_exam] + c[back_student][j], back_student)
      |                                             ^
answer.code:110:48: error: ‘c’ was not declared in this scope
  110 |                                         pair(- c[back_student][fore_exam] + c[back_student][j], back_student)
      |                                                ^
answer.code:117:33: error: ‘dead_cost’ was not declared in this scope
  117 |                                 dead_cost[inst_exam][j].insert(
      |                                 ^~~~~~~~~
answer.code:118:45: error: missing template arguments before ‘(’ token
  118 |                                         pair(- c[back_student][inst_exam] + c[back_student][j], back_student)
      |                                             ^
answer.code:118:48: error: ‘c’ was not declared in this scope
  118 |                                         pair(- c[back_student][inst_exam] + c[back_student][j], back_student)
      |                                                ^
answer.code:124:57: error: missing template arguments before ‘(’ token
  124 |                                 alive_cost[j].erase(pair(c[fore_student][j], fore_student));
      |                                                         ^
answer.code:124:58: error: ‘c’ was not declared in this scope
  124 |                                 alive_cost[j].erase(pair(c[fore_student][j], fore_student));
      |                                                          ^
answer.code:130:33: error: ‘dead_cost’ was not declared in this scope
  130 |                                 dead_cost[fore_exam][j].insert(
      |                                 ^~~~~~~~~
answer.code:131:45: error: missing template arguments before ‘(’ token
  131 |                                         pair(- c[fore_student][fore_exam] + c[fore_student][j], fore_student)
      |                                             ^
answer.code:131:48: error: ‘c’ was not declared in this scope
  131 |                                         pair(- c[fore_student][fore_exam] + c[fore_student][j], fore_student)
      |                                                ^