编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#21425 | #1001. A. 神秘谜题 | Compile Error | 0 | 0 ms | 0 K | C++ / 3.0 K | 计算机86程浩轩 | 2020-02-06 21:31:28 |
// ConsoleApplication20.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "pch.h"
#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
编译信息
/sandbox/1/a.cpp:3:10: fatal error: pch.h: No such file or directory
#include "pch.h"
^~~~~~~
compilation terminated.