QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#99526#6319. Parallel Processing (Easy)Sorting#Compile Error//C++143.1kb2023-04-22 21:16:012023-04-22 21:16:05

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-22 21:16:05]
  • 评测
  • [2023-04-22 21:16:01]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
template<class T> void check_min(T &a, const T &b){ a = (a < b) ? a : b; }
template<class T> void check_max(T &a, const T &b){ a = (a > b) ? a : b; }
#define all(x) (x).begin(), (x).end()

void output(vector<vector<array<int, 3>>> ins){
    cout << ins.size() << "\n";
    for(auto v: ins){
        for(auto [a, b, c]: v)
            cout << a << " " << b << " " << c << "\n";
    }
    exit(0);
}

void fix_add(vector<array<int, 3>> &add){
    while(add.size() != 4){
        add.push_back({2000, 2000, 2000});
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    vector<vector<array<int, 3>>> ins{
        {
            {2, 1, 2},
            {4, 3, 4},
            {6, 5, 6},
            {8, 7, 8},
        },
        {
            {3, 2, 3},
            {4, 2, 4},
            {7, 6, 7},
            {8, 6, 8},
        },
        {
            {5, 4, 5},
            {6, 4, 6},
            {7, 4, 7},
            {8, 4, 8},
        }
    };

    if(n <= 8){
        if(n <= 2){
            ins.resize(1);
            output(ins);
        }
        if(n <= 4){
            ins.resize(2);
            output(ins);
        }
        output(ins);
    }

    int start = 9;
    for(int d = 1; d <= 4; d *= 2){
        vector<array<int, 3>> add;
        if(d == 1){
            for(int x: vector{9, 11,13,15}){
                if(x + 1 > n) break;
                add.push_back({x + 1, x, x + 1});
            }
            for(int x = start; add.size() != 4 && x <= min(n, 9); ++x){
                add.push_back({x, 8, x});
                ++start;
            }
        }
        else if(d == 2){
            for(int x: vector{10, 14}){
                for(int i = 1; i <= 2; ++i){
                    if(x + i > n) break;
                    add.push_back({x + i, x, x + i});   
                }
            }
            for(int x = start; add.size() != 4 && x <= min(n, 10); ++x){
                add.push_back({x, 8, x});
                ++start;
            }
        }
        else if(d == 4){
            for(int x: vector{12}){
                for(int i = 1; i <= 4; ++i){
                    if(x + i > n) break;
                    add.push_back({x + i, x, x + i});   
                }
            }
            for(int x = start; add.size() != 4 && x <= min(n, 12); ++x){
                add.push_back({x, 8, x});
                ++start;
            }
        }
        if(add.empty()) continue;
        fix_add(add);
        ins.push_back(add);
    }
    { 
        vector<array<int, 3>> add;
        for(int i = start; i <= min(start + 3, n); ++i){
            add.push_back({i, 8, i});
        }
        start += 4;
        if(!add.empty()){
            fix_add(add);
            ins.push_back(add);
        }

        add.clear();
        for(int i = start; i <= min(start + 3, n); ++i){
            add.push_back({i, 8, i});
        }
        if(!add.empty()){
            fix_add(add);
            ins.push_back(add);
        }
    }

    output(ins);
}

Details

answer.code: In function ‘void output(std::vector<std::vector<std::array<int, 3> > >)’:
answer.code:13:18: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’
   13 |         for(auto [a, b, c]: v)
      |                  ^
answer.code: In function ‘int main()’:
answer.code:69:30: error: missing template arguments before ‘{’ token
   69 |             for(int x: vector{9, 11,13,15}){
      |                              ^
answer.code:69:30: error: expected ‘)’ before ‘{’ token
   69 |             for(int x: vector{9, 11,13,15}){
      |                ~             ^
      |                              )
answer.code:69:42: error: expected ‘;’ before ‘}’ token
   69 |             for(int x: vector{9, 11,13,15}){
      |                                          ^
      |                                          ;
answer.code:69:43: error: expected primary-expression before ‘)’ token
   69 |             for(int x: vector{9, 11,13,15}){
      |                                           ^
answer.code:79:30: error: missing template arguments before ‘{’ token
   79 |             for(int x: vector{10, 14}){
      |                              ^
answer.code:79:30: error: expected ‘)’ before ‘{’ token
   79 |             for(int x: vector{10, 14}){
      |                ~             ^
      |                              )
answer.code:79:37: error: expected ‘;’ before ‘}’ token
   79 |             for(int x: vector{10, 14}){
      |                                     ^
      |                                     ;
answer.code:79:38: error: expected primary-expression before ‘)’ token
   79 |             for(int x: vector{10, 14}){
      |                                      ^
answer.code:91:30: error: missing template arguments before ‘{’ token
   91 |             for(int x: vector{12}){
      |                              ^
answer.code:91:30: error: expected ‘)’ before ‘{’ token
   91 |             for(int x: vector{12}){
      |                ~             ^
      |                              )
answer.code:91:33: error: expected ‘;’ before ‘}’ token
   91 |             for(int x: vector{12}){
      |                                 ^
      |                                 ;
answer.code:91:34: error: expected primary-expression before ‘)’ token
   91 |             for(int x: vector{12}){
      |                                  ^