Submission #457682

# Submission time Handle Problem Language Result Execution time Memory
457682 2021-08-07T09:44:35 Z 8e7 Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
9 ms 1908 KB
//Challenge: Accepted
#include "Anna.h"
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second


void Anna(int N, vector<char> S) {
	int best = 0, bind = 0;
	for (int i = 0;i < (1<<N);i++) {
		string res;
		bool poss = 1;
		int cnt = 0;
		for (int j = 0;j < N;j++) {
			if (i & (1<<j)) {
				if (S[j] == 'Y' && (res.empty() || res.back() != 'X')) {
					poss = 0;
					break;
				}
				if (S[j] == 'Z' && (res.empty() || res.back() != 'Y')) {
					poss = 0;
					break;
				}
				if (S[j] == 'Z') {
					res.pop_back(), res.pop_back();
					cnt++;
				} else {
					res += S[j];
				}
			}
		}
		if (poss && res.empty()) {
			if (cnt > best) {
				best = cnt;
				bind = i;
			}
		}
	}
	for (int i = 0;i < N;i++) {
		Send((bind & (1<<i)) ? 1 : 0);
	}
	for (int i = 0;i < N;i++) {
		Send(S[i] == 'Z' ? 1 : 0);
		Send(S[i] == 'Y' ? 1 : 0);
	}
}
/*
g++ -std=gnu++17 -O2 -fsigned-char -o grader grader.cpp Anna.cpp Bruno.cpp
*/
//Challenge: Accepted
#include "Bruno.h"
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b ...);};
template<class T> void pary(T l, T r) {
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second


namespace {


}  // namespace

void Bruno(int N, int L, vector<int> A) {
	string s;
	vector<int> v;
	for (int i = 0;i < N;i++) {
		if (A[i] == 0) {
			//cout << i << endl;
			Remove(i);
		} else {
			int p = A[N + 2 * i] * 2 + A[N + 2 * i + 1];
			s += char('X' + p);	
			v.push_back(i);
		}
	}	
	vector<int> pos;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == 'Z') {
			//cout << pos.back()<< endl;
			Remove(pos.back());
			pos.pop_back();
			//cout << pos.back() << endl;
			Remove(pos.back());
			pos.pop_back();
			//cout << v[i] << endl;
			Remove(v[i]);
		} else {
			pos.push_back(v[i]);
		}
	}

}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for (int i = 0;i < s.size();i++) {
      |                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 492 KB Output is correct
2 Correct 6 ms 492 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 4 ms 496 KB Output is correct
5 Incorrect 9 ms 484 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1908 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -