编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#21427 #1001. A. 神秘谜题 Memory Limit Exceeded 0 787 ms 569576 K C++ / 2.8 K 计算机86程浩轩 2020-02-06 21:33:10
显示原始代码
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
using std::vector;
void turn(int a, int index, int els, int m, vector<int> &l) {
    els = a % 2;
    m = (a - els) / 2;
    if (m != 0)
        l.push_back(els);  // l最前少了一个1
    if (m != 1 && m != 0)
        turn(a, index + 1, els, m, l);
}
void ope(vector<int> &q1, vector<int> &q2) {
    int m = q1.size();
    int n = q2.size();
    vector<int> result;
    if (m > n) {
        for (int i = 0; i < m - n; i++) {
            if (q1[i] == 0)
                result.push_back(0);
            else
                result.push_back(1);
        }
        for (int j = m - n; j < m; j++) {
            if (q1[j] == 1 && q2[j - m + n] == 1)
                result.push_back(0);
            if (q1[j] == 1 && q2[j - m + n] == 0)
                result.push_back(1);
            if (q1[j] == 0 && q2[j - m + n] == 1)
                result.push_back(1);
            else
                result.push_back(0);
        }
    } else {
        for (int i = 0; i < n - m; i++) {
            if (q2[i] == 0)
                result.push_back(0);
            else
                result.push_back(1);
        }
        for (int j = n - m; j < n; j++) {
            if (q2[j] == 1 && q1[j - n + m] == 1)
                result.push_back(0);
            if (q2[j] == 1 && q1[j - n + m] == 0)
                result.push_back(1);
            if (q2[j] == 0 && q1[j - n + m] == 1)
                result.push_back(1);
            if (q2[j] == 0 && q1[j - n + m] == 0)
                result.push_back(0);
        }
    }
    q2.clear();
    for (int l = 0; l < result.size(); l++) q2.push_back(result[l]);
    result.clear();
}
int rturn(vector<int> &b1) {
    int sum = 0, temp = 1;
    for (int i = 0; i < b1.size(); i++) {
        temp = 1;
        for (int j = b1.size() - i - 1; j > 0; j--) {
            temp = temp * 2;
        }
        sum = sum + temp * b1[i];
    }
    return sum;
}
int main() {
    vector<vector<int> > a;
    int n;
    cin >> n;
    int iden, temp;
    vector<int> m, las, empty, results;
    empty.push_back(1);
    for (int i = 0; i < n; i++) {
        cin >> iden;
        for (int t = 0; t < i; t++) a.push_back(empty);
        if (iden == 2) {
            cin >> temp;
            m.push_back(temp);
            a.push_back(empty);
        } else {
            for (int j = 0; j < m.size(); j++) m[j] = m[j] + 1;
        }
        for (int s = 0; s < m.size(); s++) {
            turn(m[s], 0, 0, 0, a[s]);
        }
        results = a[0];
        for (int y = 1; y < a.size(); y++) {
            ope(a[y], results);
        }
        las.push_back(rturn(results));
        a.clear();
        results.clear();
    }
    for (int k = 0; k < las.size(); k++) cout << las[k] << endl;
    // return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing
//   code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
子任务 #1
Memory Limit Exceeded
得分:0
测试点 #1
Memory Limit Exceeded
得分:0
用时:382 ms
内存:569576 KiB

输入文件(1.in

200000
2 526767110
2 724642759
2 567837900
2 104106873
2 357915481
2 33997211
2 444788944
2 
<1586974 bytes omitted>

答案文件(1.ans

526767110
877985729
361528077
330887284
116239149
82537142
510237286
843295274
453728745
55
<2188330 bytes omitted>
测试点 #2
Memory Limit Exceeded
得分:0
用时:405 ms
内存:569548 KiB

输入文件(2.in

200000
2 515979308
2 512702340
2 684230440
2 488136957
2 598252313
2 283603971
2 349877373
2
<1586842 bytes omitted>

答案文件(2.ans

515979308
5115816
679905408
899606653
372667236
114362215
302756634
473674072
520218589
525
<2192841 bytes omitted>