# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
382959 | victoriad | Relativnost (COCI15_relativnost) | C++14 | 4078 ms | 13292 KiB |
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 <fstream>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
int mod=1e4+7;
void per(vector<int>&a,vector<int>&b,int & r,vector<int>&p,int i,int c,int nec,int u){
if(u==a.size()){
if(c>=nec){
int j=1;
for(int i=0;i<a.size();i++){
if(p[i]==1){
j*=a[i];
j=j%mod;
}
else{
j*=b[i];
j=j%mod;
}
}
r+=j;
r=r%mod;
}
return;
}
u++;
p[i]=0;
per(a,b,r,p,i+1,c,nec,u);
p[i]=1;
per(a,b,r,p,i+1,c+1,nec,u);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n,c,q,p,l,r;
cin>>n>>c;
vector<int >a(n);
vector<int>b(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
cin>>b[i];
}
cin>>q;
for(int i=0;i<q;i++){
vector<int>pr(n,0);
cin>>p>>l>>r;
a[p-1]=l;
b[p-1]=r;
int re=0;
per(a,b,re,pr,0,0,c,0);
cout<<re<<"\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |