Skip to content

Instantly share code, notes, and snippets.

@JanhaviDadhania
Created November 16, 2020 08:04
Show Gist options
  • Save JanhaviDadhania/e19cb921ba9840f918486e60ba40efe9 to your computer and use it in GitHub Desktop.
Save JanhaviDadhania/e19cb921ba9840f918486e60ba40efe9 to your computer and use it in GitHub Desktop.
#include "spoj_interactive.h"
#include <bits/stdc++.h>
#define MAX 500005
long long int a[MAX],n,cnt[MAX];
using namespace std;
void verdict_wrong(int i)
{
fprintf(spoj_for_tested,"%d\n",i);
spoj_assert(false);
}
void finalizeIT(int score)
{
fprintf(spoj_score, "%d", score);
}
int main()
{
spoj_init();
int t;
fscanf(spoj_p_in,"%d", &t);
fprintf(spoj_for_tested,"%d\n",t);
fprintf(spoj_p_info,"t : %d\n",t);
while(t--)
{
fscanf(spoj_p_in,"%lld",&n);
fprintf(spoj_for_tested,"%lld\n",n);
fprintf(spoj_p_info,"n : %lld\n",n);
int max_iterations = 55;
int hidden = 0;
fscanf(spoj_p_out,"%lld",&hidden);
fprintf(spoj_p_info, "hidden : %d", hidden);
while(max_iterations--) {
long long int x,y,z;
fscanf(spoj_t_out,"%lld",&x);
fprintf(spoj_p_info, "user : %d", x);
if(x == 0) {
if(hidden==0) {
fprintf(spoj_p_info, "user : %s", "enter 1");
fprintf(spoj_p_info, "user : %s", "correct 1");
finalizeIT(1);
}
else {
fprintf(spoj_p_info, "user : %s", "wrong 1");
verdict_wrong(-1);
}
}
else if(x == 1) {
fprintf(spoj_p_info, "user : %s", "enter 1");
if(hidden==1) {
fprintf(spoj_p_info, "user : %s", "correct 2");
finalizeIT(1);
}
else {
fprintf(spoj_p_info, "user : %s", "wrong 2");
verdict_wrong(-1);
}
}
if(n%x == 0) {
fprintf(spoj_for_tested,"%s\n","YES");
fprintf(spoj_p_info, "%s\n","YES");
}
else {
fprintf(spoj_for_tested,"%s\n","NO");
fprintf(spoj_p_info, "%s\n","NO");
}
}
}
// long long int querylimit= n;
// long long int i,j;
// memset(a,0,sizeof(a));
// memset(cnt,0,sizeof(cnt));
// for(i=1;i<=n;i++)
// {
// fscanf(spoj_p_in,"%lld",&a[i]);
// fprintf(spoj_p_info,"array element : %lld",a[i]);
// }
// j=0;
// bool ac=false;
// int ch;
// while(true)
// {
// j++;
// fscanf(spoj_t_out,"%d",&ch);
// if(ch!=1)
// {
// break;
// }
// if(j<=querylimit)
// {
// long long int x,y,z;
// fscanf(spoj_t_out,"%lld",&x);
// fscanf(spoj_t_out,"%lld",&y);
// fscanf(spoj_t_out,"%lld",&z);
// cnt[x]++;cnt[y]++;cnt[z]++;
// if(x<=n && y<=n && z<=n && x>=1 && y>=1 && z>=1 && cnt[x]<=3 && cnt[y]<=3 && cnt[z]<=3)
// {
// fprintf(spoj_for_tested,"%lld\n",(a[x]^a[y]^a[z]));
// fprintf(spoj_p_info,"we out : %lld\n",(a[x]^a[y]^a[z]));
// }
// else
// {
// verdict_wrong(-1);
// }
// }
// else
// {
// break;
// }
// }
// if(ch==2)
// {
// long long int x,fl=1;
// for(i=1;i<=n;i++)
// {
// fscanf(spoj_t_out,"%lld",&x);
// fprintf(spoj_p_info,"final : %lld",x);
// if(x!=a[i])
// fl=0;
// }
// if(fl)
// {
// fprintf(spoj_for_tested,"%d\n",1);
// ac=true;
// }
// }
// if(!ac)
// {
// fprintf(spoj_p_info,"ac : %d\n", ac);
// verdict_wrong(-1);
// }
// fprintf(spoj_p_info,"ac : %d\n", ac);
// }
// finalizeIT(1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment