QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#49027 | #2281. BnPC | asdasdasfasdfasdfsdaf | Compile Error | / | / | C++ | 1.9kb | 2022-09-19 05:38:51 | 2022-09-19 05:38:54 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-09-19 05:38:54]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-09-19 05:38:51]
- 提交
answer
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cstring>
#include <functional>
struct action
{
uint64_t name;
int power;
action(uint64_t _name, uint64_t power) : name(_name), power(_power)
{
}
};
inline int calculate_score( const std::vector<action>& actions, const std::vector<action>& events )
{
int score = 0;
for( const action& rAction : actions ) {
for( const action& rEvent : events ) {
if( rAction.name != rEvent.name )
continue;
if( rAction.power > rEvent.power )
score += rAction.power;
}
}
return score;
}
int main()
{
int n, k;
std::cin >> n; std::cin >> k;
std::vector<action> action_list( n );
char name[21];
int power;
for( int i = 0; i < n; i++ ) {
std::cin >> name; std::cin >> power;
action_list.emplace_back( std::hash<std::string>{}( name ), power );
}
int l;
std::cin >> l;
std::vector<action> event_list( l );
for( int i = 0; i < l; i++ ) {
char name[21];
std::cin >> name; std::cin >> power;
event_list.emplace_back( std::hash<std::string>{}( name ), power );
}
for( action& rAction : action_list ) {
for( const action& rEvent : event_list ) {
if( rAction.name != rEvent.name )
continue;
if( rAction.power < rEvent.power ) {
int delta = rEvent.power - rAction.power;
rAction.power += delta;
k -= delta;
if( k < 0 ) {
std::cout << 0;
return 0;
}
}
}
}
int max_score = 0;
while( k ) {
int target_index = 0;
max_score = -1;
for( int i = 0; i < n; i++ ) {
action_list[i].power++;
int score = calculate_score( action_list, event_list );
if( score > max_score ) {
target_index = i;
max_score = score;
}
action_list[i].power--;
}
action_list[target_index].power++;
k--;
}
std::cout << max_score;
return 0;
}
Details
answer.code: In constructor ‘action::action(uint64_t, uint64_t)’: answer.code:14:69: error: ‘_power’ was not declared in this scope; did you mean ‘power’? 14 | action(uint64_t _name, uint64_t power) : name(_name), power(_power) | ^~~~~~ | power In file included from /usr/include/c++/11/bits/alloc_traits.h:33, from /usr/include/c++/11/ext/alloc_traits.h:34, from /usr/include/c++/11/bits/basic_string.h:40, from /usr/include/c++/11/string:55, from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from answer.code:1: /usr/include/c++/11/bits/stl_construct.h: In instantiation of ‘void std::_Construct(_Tp*, _Args&& ...) [with _Tp = action; _Args = {}]’: /usr/include/c++/11/bits/stl_uninitialized.h:579:18: required from ‘static _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = action*; _Size = long unsigned int; bool _TrivialValueType = false]’ /usr/include/c++/11/bits/stl_uninitialized.h:640:20: required from ‘_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = action*; _Size = long unsigned int]’ /usr/include/c++/11/bits/stl_uninitialized.h:704:44: required from ‘_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, std::allocator<_Tp>&) [with _ForwardIterator = action*; _Size = long unsigned int; _Tp = action]’ /usr/include/c++/11/bits/stl_vector.h:1606:36: required from ‘void std::vector<_Tp, _Alloc>::_M_default_initialize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = action; _Alloc = std::allocator<action>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]’ /usr/include/c++/11/bits/stl_vector.h:512:9: required from ‘std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = action; _Alloc = std::allocator<action>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<action>]’ answer.code:38:37: required from here /usr/include/c++/11/bits/stl_construct.h:109:7: error: no matching function for call to ‘action::action()’ 109 | { ::new(static_cast<void*>(__p)) _Tp(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:14:9: note: candidate: ‘action::action(uint64_t, uint64_t)’ 14 | action(uint64_t _name, uint64_t power) : name(_name), power(_power) | ^~~~~~ answer.code:14:9: note: candidate expects 2 arguments, 0 provided answer.code:9:8: note: candidate: ‘constexpr action::action(const action&)’ 9 | struct action | ^~~~~~ answer.code:9:8: note: candidate expects 1 argument, 0 provided answer.code:9:8: note: candidate: ‘constexpr action::action(action&&)’ answer.code:9:8: note: candidate expects 1 argument, 0 provided