 # EQUINOX - Editorial

I have already defined #define int long long .

Hi All,
This is the solution which I had submitted yesterday but it was not accepted.
I checked the setter solution and the logic is exactly the same.

`````` #include <iostream>
#include <string>
using namespace std;

int main() {
int testCase, N, A, B;
int pointsA, pointsB;
string input;

for (cin >> testCase; testCase != 0; testCase--) {
cin >> N >> A >> B;
pointsA = 0;
pointsB = 0;

for (int i = 0; i < N; i++) {
cin >> input;

switch (input) {
case 'E':
case 'Q':
case 'U':
case 'I':
case 'N':
case 'O':
case 'X':
pointsA += A;
break;
default:
pointsB += B;
}
}
if (pointsA == pointsB) {
cout << "Draw\n";
} else {
if (pointsA > pointsB) {
cout << "Sarthak\n";
} else {
}
}
}
return 0;
}``````

Can anyone please tell me what is the wrong in this code. It is not submitted.

#include<bits/stdc++.h>
using namespace std;
#include
#include

#define ll long long
int main()
{
int t;
cin>>t; string s=“EQUINOX”;
while(t–) {
ll n,a,b,sar=0,anu=0;
cin>>n>>a>>b;

``````    // vector<string>v(n);
// for(int i=0;i<n;i++)
// cin>>v[i];

bool flag=false;
for(ll i=0;i<n;i++) {
string str; cin>>str;  flag=false;
for(ll k=0;k<s.size();k++) {
if(str==s[k])
flag=true;
// break;
}
if(flag)
sar+=a;
else
anu+=b;

}

if(sar>anu) cout<<"SARTHAK";
else cout<<"DRAW\n";

}
return 0;
``````

}

It may due to your while case- while(t-)

Hi Cubefreak,

According to the constraints
A and B will be lesser than or equal to 10^9
While the limit of int is 2147483647
While is definitely above 10^9

The mistake was in constraints. Please have a look.

EDIT: Ok I found the mistake in the code. Yes, it should be long long. One single overlook can cause big problems.

1 Like

//
// main.cpp
// Equinox
//
// Created by Anurag on 30/04/21.
//

#include
using namespace std;
int main() {
int t;
cin>>t;
while(t–)
{
long long int n;
long long int *a=new long long int ;
long long int *b=new long long int ;
cin>>n>>*a>>*b;
string str;
int sar=0,anu=0;
while(n–)
{
cin>>str;
if(str==‘E’ || str==‘Q’ || str==‘U’ || str==‘I’ || str==‘N’ || str==‘O’ || str==‘X’)
{
sar+=*a;
}
else{
anu+=*b;
}
}
//cout<<sar<<" "<<anu<<endl;
if(anu==sar)
{
cout<<“DRAW”<<endl;
}
else if(anu>sar)
{
}
else if(sar>anu)
{
cout<<“SARTHAK”<<endl;
}
}
return 0;
}
Why is this coding giving wrong answer on submission .plz help

He has used long long int. See the macros above. Although I think as an one star coder, he sure has one hell of a template. He does not even know to use it. He has already defined a macro for for loop and still using the whole statement in his code.

As we are using long long in C++ ,What should I suppose to take in java .! to take Constraints of A and B (1≤A, B≤10^9).?

Here’s my code : Error Page | CodeChef

public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
int T = sc.nextInt();
for(int i=0 ; i<T ; i++) {
int N = sc.nextInt();
int A = sc.nextInt();
int B = sc.nextInt();

``````		String[] s = new String[N];

sc.nextLine();

for(int j = 0 ;j<N ;j++) {
s[j] = sc.nextLine();
}

int ta = 0 ;
int ts = 0 ;
for(int x = 0 ; x<N ;x++) {
if(s[x].charAt(0)=='E' || s[x].charAt(0)=='Q' || s[x].charAt(0)=='U' || s[x].charAt(0)=='I' || s[x].charAt(0)=='N' || s[x].charAt(0)=='O' || s[x].charAt(0)=='X') {
ts += A;
}
else {
ta += B;
}
}

if(ts>ta)
System.out.println("SARTHAK");

if(ts<ta)

if(ta==ts)
System.out.println("DRAW");

}
``````

can anyone tell me why this is giving me a wrong verdict !?

Can someone help me with my code, Ive run it on some testcases and it yielded correct answers. But it doesn’t seem to accept the submission!

int t;
cin>>t;
while(t–) {
int a, b, n, sa=0, sb=0;
string z;
cin>>n>>a>>b;
std::vector v;
char y[] = {‘E’, ‘Q’, ‘U’, ‘I’, ‘N’, ‘O’, ‘X’};
for(int i=0;i<n;i++) {
cin>>z;
v.push_back(z);
}
bool flag;
for(auto it: v) {
flag = false;
for(auto x: y) {
if(it==x) {
sa+=a;
flag = true;
break;
}
}
if(!flag) {
sb+=b;
}
}
if(sa==sb) {
cout<<“DRAW”<<endl;
} else if(sa>sb) {
cout<<“SARTHAK”<<endl;
} else {
}
}

i think it is unnecessary line, remove it.

#include<stdio.h>
#include<string.h>

#define MAX 100
#define int long long
void equinox(void);

char str[] = {“EQUINOX”};

int main()
{
int t;

``````scanf("%d", &t);

while(t!=0)
{
equinox();
t--;
}

return 0;
``````

}

void equinox()
{
int n, a, b, A= 0, B= 0, j, flag =0;
char S[MAX];
extern char str[];
scanf("%d %d %d", &n, &a, &b);

``````while(n!=0)
{
gets(S);
for(j=0;j < strlen(str); j++)
{
if(S == str[j])
flag = 1;
}
if(flag==1) A = A + a;
else B = B + b;
n--;
flag=0;
}

if(A == B) printf("DRAW\n");
else if(A>B) printf("SARTHAK\n");
``````

}

my program shows time limit exceeded what should i do?
Solution: 45730009 | CodeChef

Please look at the constraints. A and B can be as large as 10^9, and N can be up to 100.

Try this input:

``````1
3 1 100
OAAA
AOAA
AAOA
``````

It’s nearly perfect! Try this input:

``````3
2 1 100
EAA
AEE
2 1 100
EAA
AEE
2 1 100
EAA
AEE``````

USE LONG LONG INT sc1,sc2 INSTEAD OF INT.

just use long long int sa sb as int is not enough for this problem

this is my code and I’ve got it correct for test cases but I am getting work answer for submission …please anyone help me with this…

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
private static boolean check(char ch)
{
String s=“EQUINOX”;
for(int i=0;i<s.length();i++)
{
if(s.charAt(i)==ch)
return true;
}
return false;
}
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
short t=sc.nextShort();
while(t>0)
{
t–;
short n;
int a,b,x=0,y=0;
n=sc.nextShort();
a=sc.nextInt();
b=sc.nextInt();
while(n>0)
{
n–;
String s;
s=sc.next();
if(check(s.charAt(0)))
x+=a;//sarthak
else
}
if(x>y)
System.out.println(“SARTHAK”);
else if(x==y)
System.out.println(“DRAW”);
else if(x<y)
``````	}