Submission #1132170


Source Code Expand

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<set>
#include<functional>
#define P pair<int,int>
using namespace std;

int main() {
	int a; cin >> a;
	if (a <= 8) {
		int S = 0;
		int b[8];
		for (int c = 0; c < a; c++)cin >> b[c];
		int c[8];//ゴールする順番
		for (int i = 0; i < a; i++)c[i] = i;
		bool aru[8];
		do {
			bool OK = true;
			int copy[8];
			for (int i = 0; i < a; i++)copy[i] = b[i];
			memset(aru, true, sizeof(aru));
			for (int i = 0; i < a; i++) {//c[i]体目がゴールする
				vector<P>V;
				for (int j = 0; j < a; j++) {
					if (aru[j] && copy[j] < copy[c[i]]) {
						V.push_back(P(copy[j], j));
					}
				}
				sort(V.begin(), V.end(), greater<P>());
				for (int k = 0; k + 1 < (int)V.size(); k++) {
					if (V[k].first - 1 <= V[k + 1].first) {
						V[k + 1].first = V[k].first - 2;
					}
				}
				for (int k = 0; k < V.size(); k++) {
					copy[V[k].second] = V[k].first;
					if (V[k].first <= 0)OK = false;
				}
				aru[c[i]] = false;
			}
			if (OK) { S++; }
		} while (next_permutation(c, c + a));
		cout << S << endl;
	}
}

Submission Info

Submission Time
Task A - Robot Racing
User naoki2016
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1236 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:27:33: error: ‘memset’ was not declared in this scope
    memset(aru, true, sizeof(aru));
                                 ^