Submission #99378

# Submission time Handle Problem Language Result Execution time Memory
99378 2019-03-03T10:08:56 Z Ort Hokej (COCI17_hokej) C++11
Compilation error
0 ms 0 KB
#include<iostream>
#include<algorithm>
#include<vector>
#define MAX 10000
#define ll long long

using namespace std;

bool cmp(const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b) {
	if(a.first.first==b.first.first) return a.second < b.second;
	else return a.first.first>b.first.first;
}

int m, n, strength, endurance, id, t, time, time_passed, block, sub;
ll total;
vector<pair<pair<int,int>, int> > players;
vector<int> starters;
vector<pair<int,int> > sol[MAX];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	cin >> m >> n; time = m;
	for(int i=1;i<=n;i++) {
		cin >> strength >> endurance;
		players.push_back({{strength,endurance},i});
	}
	sort(players.begin(),players.end(),cmp);
	while(t<n && block<6) {
		strength = players[t].first.first;
		endurance = players[t].first.second;
		id = players[t].second;
		if(endurance==0) {
			t++;
			continue;
		}
		time = min(endurance, m-time_passed);
		if(time_passed==0 && starters.size()<6) {
			starters.push_back(id);
		}
		else if(t-1>0) {
			sub++;
			sol[time_passed].push_back({players[t-1].second,id});
		}
		time_passed += time;
		total += (ll)time*strength;
		players[t].first.second -= time;
		if(time_passed==m) {
			block++;
			time_passed = 0;
		}
	}
	cout << total << "\n";
	for(int i=0;i<6;i++) cout << starters[i] << " ";
	cout << "\n" << sub << "\n";
	for(int i=0;i<m;i++) {
		for(int j=sol[i].size()-1;j>=0;j--) {
			cout << i << " " << sol[i][j].first << " " << sol[i][j].second;
			cout << "\n";
		}
	}
	return 0;
}

Compilation message

hokej.cpp:14:39: error: 'int time' redeclared as different kind of symbol
 int m, n, strength, endurance, id, t, time, time_passed, block, sub;
                                       ^~~~
In file included from /usr/include/pthread.h:24:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/gthr.h:148,
                 from /usr/include/c++/7/ext/atomicity.h:35,
                 from /usr/include/c++/7/bits/ios_base.h:39,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from hokej.cpp:1:
/usr/include/time.h:192:15: note: previous declaration 'time_t time(time_t*)'
 extern time_t time (time_t *__timer) __THROW;
               ^~~~
hokej.cpp: In function 'int main()':
hokej.cpp:23:24: error: assignment of function 'time_t time(time_t*)'
  cin >> m >> n; time = m;
                        ^
hokej.cpp:23:24: error: cannot convert 'int' to 'time_t(time_t*) throw () {aka long int(long int*) throw ()}' in assignment
hokej.cpp:37:38: error: assignment of function 'time_t time(time_t*)'
   time = min(endurance, m-time_passed);
                                      ^
hokej.cpp:37:38: error: cannot convert 'const int' to 'time_t(time_t*) throw () {aka long int(long int*) throw ()}' in assignment
hokej.cpp:45:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   time_passed += time;
   ~~~~~~~~~~~~^~~~~~~
hokej.cpp:45:15: error: invalid conversion from 'time_t (*)(time_t*) throw () {aka long int (*)(long int*) throw ()}' to 'int' [-fpermissive]
hokej.cpp:47:27: error: invalid operands of types 'int' and 'time_t(time_t*) throw () {aka long int(long int*) throw ()}' to binary 'operator-'
   players[t].first.second -= time;
hokej.cpp:47:30: error:   in evaluation of 'operator-=(int, time_t(time_t*) throw () {aka long int(long int*) throw ()})'
   players[t].first.second -= time;
                              ^~~~