This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include"trilib.h"
using namespace std;
int N;
vector<vector<int>> good(deque<int> v){
vector<vector<int>> res;
for(int i = 0; i<v.size(); i++){
res.push_back(vector<int>(v.begin(), v.end()));
int val= v.back();
v.push_front(val);
v.pop_back();
}
return res;
}
signed main(){
N = get_n();
vector<vector<vector<bool>>> above(N, vector<vector<bool>>(N, vector<bool>(N, false)));
vector<vector<vector<bool>>> know(N, vector<vector<bool>>(N, vector<bool>(N, false)));
auto not_removed = [&](int i, int j, int k){
for(auto e: good({i, j, k})){
if(know[e[0]][e[1]][e[2]] && !above[e[0]][e[1]][e[2]]){
return false;
}
}
for(auto e: good({j,i, k})){
if(know[e[0]][e[1]][e[2]] && above[e[0]][e[1]][e[2]]){
return false;
}
}
return true;
};
for(int i = 0; i<N; i++){
for(int j = i+1; j<N; j++){
for(int k = j+1; k<N; k++){
if(not_removed(i, j, k)){
bool this_order = is_clockwise(i+1, j+1, k+1);
vector<int> res({i, j, k});
bool ok = true;
while(ok){
know[res[0]][res[1]][res[2]] =true;
ok = next_permutation(res.begin(), res.end());
}
for(auto e: good({i, j, k})){
above[e[0]][e[1]][e[2]] = this_order;
}
for(auto e: good({j,i, k})){
above[e[0]][e[1]][e[2]] = !this_order;
}
}
}
}
}
int res= 0;
for(int i = 0; i<N; i++){
for(int j = 0; j<N; j++){
int count_above = 0;
for(int k = 0; k<N; k++){
if(above[i][j][k]){
count_above++;
}
}
if(count_above == N-2){
res++;
}
}
}
cout<<res<<endl;
}
Compilation message (stderr)
tri.cpp: In function 'std::vector<std::vector<int> > good(std::deque<int>)':
tri.cpp:10:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | for(int i = 0; i<v.size(); i++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |