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 "vision.h"
using namespace std;
int nbLig,nbCol,distObj;
vector<int> listeLig,listeCol,distLig,distCol;
bool estPN(int nb) {
int div=2,nbFact=0;
while (nb>1) {
if (nb%div==0) {
while (nb%div==0) {
nb/=div;
}
nbFact++;
}
div++;
}
return (nbFact<=1);
}
vector<int> calcDist(vector<int> val) {
vector<int> rep,quest,globQuest;
vector<pair<int,int>> listePN;
int taille=val.size(),temp;
rep.push_back(add_xor(val));
if (taille>1) {
for (int i=1;i<taille;i++) {
if (estPN(i)) {
//cout<<i<<" ";
globQuest.clear();
for (int j=0;j<i;j++) {
quest.clear();
for (int k=j;k<taille;k+=i) {
quest.push_back(val[k]);
}
if (quest.size()>1) {
globQuest.push_back(add_and({add_or(quest),add_not(add_xor(quest))}));
}
}
listePN.push_back({i,add_or(globQuest)});
temp=add_not(listePN.back().second);
}
}
for (int i=1;i<taille;i++) {
quest.clear();
for (auto div:listePN) {
if (i%div.first==0) {
quest.push_back(div.second);
}
else {
quest.push_back(div.second+1);
}
}
rep.push_back(add_and(quest));
}
}
/*else {
for (int i=1;i<taille;i++) {
quest.clear();
for (int a=0;a<taille;a++) {
for (int b=a+1;b<taille;b++) {
if (b-a==i) {
quest.push_back(add_and({val[a],val[b]}));
}
}
}
rep.push_back(add_or(quest));
}
}*/
return rep;
}
void construct_network(int H, int W, int K) {
nbLig=H;
nbCol=W;
distObj=K;
vector<int> quest;
for (int j=0;j<nbCol;j++) {
quest.clear();
for (int i=0;i<nbLig;i++) {
quest.push_back(i*nbCol+j);
}
listeCol.push_back(add_or(quest));
}
distCol=calcDist(listeCol);
for (int i=0;i<nbLig;i++) {
quest.clear();
for (int j=0;j<nbCol;j++) {
quest.push_back(i*nbCol+j);
}
listeLig.push_back(add_or(quest));
}
distLig=calcDist(listeLig);
quest.clear();
for (int i=0;i<nbLig;i++) {
for (int j=0;j<nbCol;j++) {
if (i+j==distObj) {
quest.push_back(add_and({distLig[i],distCol[j]}));
}
}
}
add_or(quest);
}
Compilation message (stderr)
vision.cpp: In function 'std::vector<int> calcDist(std::vector<int>)':
vision.cpp:26:27: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
26 | int taille=val.size(),temp;
| ^~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |