QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#581074#8129. Binary Sequenceucup-team1766#WA 47ms19316kbC++171.4kb2024-09-22 06:40:422024-09-22 06:40:42

Judging History

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

  • [2024-09-22 06:40:42]
  • 评测
  • 测评结果:WA
  • 用时:47ms
  • 内存:19316kb
  • [2024-09-22 06:40:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int MAXS = 39;
string strs[MAXS];

string get_next(string& str){
	string temp;
	int am = 0;
	char prev = '1';
	for(int i = 0; i < str.size(); i++){
		if(str[i] == prev){
			am++;
		}else{
			string temp2;
			while(am > 0){
				if(am & 1){
					temp2.push_back('1');
				}else{
					temp2.push_back('0');
				}
				am /= 2;
			}
			reverse(temp2.begin(), temp2.end());
			temp += temp2;
			temp += prev;
			am = 1;
		}
		prev = str[i];
	}
	string temp2;
	while(am > 0){
		if(am & 1){
			temp2.push_back('1');
		}else{
			temp2.push_back('0');
		}
		am /= 2;
	}
	reverse(temp2.begin(), temp2.end());
	temp += temp2;
	temp += prev;
	return temp;
}

void solve() {
    long long n;
    int m;
    cin >> n >> m;
    n--;

    if (n < MAXS && m >= strs[n].length()) {
        return;
    }

    if (n % 2 == 0) {
        int len = strs[MAXS - 1].length();
        cout << strs[MAXS - 1][len - m - 1] << "\n";
    } else {
        int len = strs[MAXS - 2].length();
        cout << strs[MAXS - 2][len - m - 1] << "\n";
    }
}

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

    strs[0] = "1";
    for (int i = 1; i < MAXS; i++) {
        strs[i] = get_next(strs[i - 1]);
    }

    for (int i = 0; i < 5; i++) {
        cout << strs[i] << "\n";
    }

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}


详细

Test #1:

score: 0
Wrong Answer
time: 47ms
memory: 19316kb

input:

10
4 0
4 1
4 2
4 3
4 4
4 5
4 6
6 3
6 7
118999881999119725 3

output:

1
11
101
111011
11110101
1
1
0
1
1
1
1
1
0

result:

wrong answer 2nd numbers differ - expected: '1', found: '11'