Please read the new rule regarding the restriction on the use of AI tools. ×

Why did it give wrong answer?

Revision en1, by siegreich, 2022-04-22 12:23:02

I faced this problem during solving a problem of Codeforces Round #784 (Div 4) (https://codeforces.me/contest/1669). I tried the following code for problem A which gave perfect output in the pc but when I submitted the verdict was wrong answer for same input.

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define yes printf("YES\n")
#define no printf("NO\n")
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
//#define srt_v sort(v.begin(),v.end())
#define srt_v(n) sort(v,v+n)
#define all(v) v.begin(),v.end()
#define tc int test;scanf("%d", &test);while(test--)
#define sc(n) ;scanf("%d", &n)
#define rep(i,a,b) for(int i=a; i<b; i++)
#define rev(i,a,b) for(int i=a; i>=b; i--)
#define vpi vector<pair<int,int> >
#define MAX  100000002

void solve()
{
    int n;
    cin>>n;
    if(n>=1900)
        printf("Division 1\n");
    else if(n>=1600)
        printf("Division 2\n");
    else if(n>=1400)
        printf("Division 3\n");
    else
        printf("Division 4\n");
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    tc{
    solve();
    }
    return 0;
}

My submission link: https://codeforces.me/contest/1669/submission/154321972

But when I changed the code, it got accepted. It appeared to me that #define tc is not working. Why is it so?

void solve()
{
    int test;
    scanf("%d", &test);
    while(test--){
    int n;
    scanf("%d", &n);
    if(n>=1900)
        printf("Division 1\n");
    else if(n>=1600)
        printf("Division 2\n");
    else if(n>=1400)
        printf("Division 3\n");
    else
        printf("Division 4\n");
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    ///tc{
    solve();
    ///}
    return 0;
}

My submission link: https://codeforces.me/contest/1669/submission/154343671

Tags round#784(div 4), problem a, wrong answer on test 1

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English siegreich 2022-04-22 12:31:42 380
en1 English siegreich 2022-04-22 12:23:02 1959 Initial revision (published)