/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 2ms 328.0 KiB
#3 Wrong Answer 2ms 796.0 KiB
#4 Wrong Answer 2ms 572.0 KiB

Code

#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define ll long long int
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define mx_ele(v) *max_element(v.begin(),v.end())
#define mnm_ele(v) *min_element(v.begin(),v.end())
#define endl "\n"
using namespace std;

void smile()
{
    string eqn;
    cin >> eqn;
    int slope = 0, c = 0;

    if (eqn.size() == 6)
    {
        eqn[2] = eqn[2] - '0';
        eqn[5] = eqn[5] - '0';
        slope = eqn[2];
        c = eqn[5];
        if (eqn[4] == '-')
            c = (-1) * c;
    }
    else if (eqn.size() == 7)
    {
        eqn[3] = eqn[3] - '0';
        eqn[6] = eqn[6] - '0';
        if(eqn[2]=='-')
            slope = (-1) * eqn[3];
        else
            slope=eqn[3];
        c = eqn[6];
        if(eqn[5]=='-')
            c=(-1)*c;

    }
    else if (eqn.size() == 5 and eqn[2]=='-')
    {
        eqn[3] = eqn[3] - '0';
        slope = eqn[3];
        if (eqn[2] == '-')
            slope = (-1) * slope;
        c = 0;
    }
    else if(eqn.size()==5 and eqn[2]=='x')
    {
        slope=1;
        eqn[4]=eqn[4]-'0';
        c=eqn[4];
        if(eqn[3]=='-')
            c=(-1)*c;
    }
    else if (eqn.size() == 4 and eqn[3] == 'x')
    {
        eqn[2] = eqn[2] - '0';
        slope = eqn[2];
        c = 0;
    }
    else if (eqn.size() == 3)
    {
        eqn[2] = eqn[2] - '0';
        slope = 0;
        c = eqn[2];
    }
    else if (eqn.size() == 4)
    {
        slope = 0;
        eqn[3] = eqn[3] - '0';
        c = (-1) * eqn[3];
    }
    long long  t;
    cin>>t;
    while(t--)
    {
        long long int x,y;
        cin>>x>>y;
        long long int  first=slope*x;
        long long int  fina=first+c;
        if(fina==y)
            yes;
        else no;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--)
    {
        smile();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1015 Friend in need is a friend indeed
Contest
Brain booster - 1
Language
C++17 (G++ 13.2.0)
Submit At
2023-12-31 16:29:51
Judged At
2024-11-11 03:45:08
Judged By
Score
30
Total Time
2ms
Peak Memory
796.0 KiB