Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这个H2O题怎么这么点人AC?

Posted by KatrineYang at 2016-07-16 22:05:05 on Problem 1105
#include <iostream>
#include <string>
using namespace std;

int main() {
	int cnt = 0;
	while(1){
		cnt ++;
		int numVar;
		cin >> numVar;
		if(numVar == 0) return 0;
		cout << "S-Tree #" << cnt << ":\n";
		int state[128];
		int order[7];
		string s;
		for(int i = 0; i < numVar; i++){
			cin >> s;
			order[i] = s[1] - '1';
		}
		cin >> s;
		for(int i = 0; i < (1<<numVar); i++){
			state[i] = s[i] - '0';
		}
		int cases;
		cin >> cases;
		for(int i = 0; i < cases; i++){
			cin >> s;
			int idx = 0;
			for(int j = 0; j < numVar; j++){
				idx += (s[order[j]]-'0') << (numVar - 1 - j);
			}
			cout << state[idx];
		}
		cout << endl << endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator