QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#815622#9802. Light Up the Gridtamir#Compile Error//C++202.3kb2024-12-15 15:59:242024-12-15 15:59:30

Judging History

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

  • [2024-12-15 15:59:30]
  • 评测
  • [2024-12-15 15:59:24]
  • 提交

answer

#include<iostream>
using namespace std;

using ll = long long;

ll dp[(1 << 17)];
int a[4];
int cost[16];

ll solve(int mask) {
    if(mask == 0)return 0ll;
    if(dp[mask] != -1)return dp[mask];
    ll res = 1e18;
    for(int i = 0; i < 16; i++){
        if(mask & (1 << i)){
            int newmask = 0;
            for(int j = 0; j < 16; j++){
                if(i == j || !(mask & (1 << j)))continue;
                int tmp = j;
                for(int k = 0; k < 4; k++) {
                    if(!(i & (1 << k))) {
                        tmp ^= (1 << k);           
                    }
                }
                newmask |= (1 << tmp);
            }
            res = min(res, cost[i] + solve(newmask));
            
        }
    }
    return dp[mask] = res;
}

void solve() {
    int n;
    cin >> n;

    
    int mask = 0;
    for(int i = 0; i < n; i++){
        vector<string> b(2);
        for(int j = 0; j < 2; j++){
            cin >> b[j];
        }
        int cur = 0;
        if(b[1][1] == '1'){
            cur |= 1;
        }
        if(b[1][0] == '1'){
            cur |= (1 << 1);
        }
        if(b[0][1] == '1'){
            cur |= (1 << 2);
        }
        if(b[0][0] == '1'){
            cur |= (1 << 3);
        }
        mask |= (1 << cur);
    }
    cout << solve(mask) << '\n';
}

int main() {
    ios::sync_with_stdio(0); cin.tie(nullptr);

    int t = 1;
    cin >> t;
    for(int i = 0; i < 4; i++) cin >> a[i];

    for(int i = 0; i < 16; i++) {
        if(i == 0) {
            cost[i] = min({a[0] * 4, a[1] * 2, a[2] * 2, a[3]});
        }
        if(i == 4 || i == 1 || i == 2 || i == 8) {
            cost[i] = min({a[0] * 3, a[0] + a[1], a[0] + a[2], a[0] + a[3]});
        }
        if(i == 12 || i == 3){
            cost[i] = min({a[0] * 2, a[1]});
        }
        if(i == 10 || i == 5){
            cost[i] = min({a[0] * 2, a[2]});
        }
        if(i == 6 || i == 9) {
            cost[i] = min({a[0] * 2, a[1] + a[2]});
        }
        if(i == 7 || i == 13 || i == 11 || i == 14) {
            cost[i] = a[0];
        }
        if(i == 15) {
            cost[i] = min({a[0] * 2, a[1] * 2, a[2] * 2, a[3] * 2});
        }
    }
    memset(dp, -1, sizeof(dp));    
    while(t--){
        solve();
    }
}

Details

answer.code: In function ‘void solve()’:
answer.code:41:9: error: ‘vector’ was not declared in this scope
   41 |         vector<string> b(2);
      |         ^~~~~~
answer.code:2:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | using namespace std;
answer.code:41:22: error: expected primary-expression before ‘>’ token
   41 |         vector<string> b(2);
      |                      ^
answer.code:41:24: error: ‘b’ was not declared in this scope
   41 |         vector<string> b(2);
      |                        ^
answer.code: In function ‘int main()’:
answer.code:72:26: error: no matching function for call to ‘min(<brace-enclosed initializer list>)’
   72 |             cost[i] = min({a[0] * 4, a[1] * 2, a[2] * 2, a[3]});
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/string:51,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:72:26: note:   candidate expects 2 arguments, 1 provided
   72 |             cost[i] = min({a[0] * 4, a[1] * 2, a[2] * 2, a[3]});
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:72:26: note:   candidate expects 3 arguments, 1 provided
   72 |             cost[i] = min({a[0] * 4, a[1] * 2, a[2] * 2, a[3]});
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:75:26: error: no matching function for call to ‘min(<brace-enclosed initializer list>)’
   75 |             cost[i] = min({a[0] * 3, a[0] + a[1], a[0] + a[2], a[0] + a[3]});
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:75:26: note:   candidate expects 2 arguments, 1 provided
   75 |             cost[i] = min({a[0] * 3, a[0] + a[1], a[0] + a[2], a[0] + a[3]});
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:75:26: note:   candidate expects 3 arguments, 1 provided
   75 |             cost[i] = min({a[0] * 3, a[0] + a[1], a[0] + a[2], a[0] + a[3]});
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:78:26: error: no matching function for call to ‘min(<brace-enclosed initializer list>)’
   78 |             cost[i] = min({a[0] * 2, a[1]});
      |                       ~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:78:26: note:   candidate expects 2 arguments, 1 provided
   78 |             cost[i] = min({a[0] * 2, a[1]});
      |                       ~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:78:26: note:   candidate expects 3 arguments, 1 provided
   78 |             cost[i] = min({a[0] * 2, a[1]});
      |                       ~~~^~~~~~~~~~~~~~~~~~
a...