I faced this problem during solving a problem of Codeforces Round #784 (Div 4) (https://codeforces.net/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.net/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.net/contest/1669/submission/154343671