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

Problem using templates(Compilation error)

Revision en1, by Afridi_Haque, 2022-10-25 19:03:42

Hi Programmers, I am new to CP, I made my CP template but it's showing error while using some of it's features. Below I am pasting the template snippet, and later will post the error.

//	Headers
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pdbs;
using namespace std;

//	Special Numbers
#define mod 1000000007
#define inf 1e18

//	Datatypes
#define ll long long
#define double long long double

//	Vector operations
#define pb push_back
#define v(int) vector<long long>
#define vb v.begin()
#define ve v.end()

//	Pair operations
#define pll pair<long, long>
#define f first
#define s second
#define mp make_pair

//	Loops
#define w(t) int t; cin >> t; while(t--)
#define forn(a,b) for(int i = a; i < b; i++)
#define forr(a,b) for(int i = a; i >= b; i--)

//	Printing Outputs
#define py cout<<"YES"<<endl;
#define pn cout<<"NO"<<endl;

//	Driver Function Start
//	Type Code from here
int main(){
	
	return 0;
}

My code is —

int main(){
	int xsum = 0, ysum = 0, zsum = 0;
	w(t){
		int x, y, z;
		cin >> x >> y >> z;
		xsum += x;
		ysum += y;
		zsum += z;
	}
	
	if(xsum == 0 && ysum == 0 && zsum == 0)	py;
	else	pn;
	return 0;
}

But it's showing error for — py and pn definitions(last 2 lines of template). The error follows as -

49 2 C:\Users\AFRIDI\OneDrive\Desktop\CP\A2OJ\Young Physicist.cpp [Error] 'else' without a previous 'if'

Please help me to find a way out. Your help will be appreciated. In comments I am posting the error screen shot.

Tags cp, newbie, compilation error

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Afridi_Haque 2022-10-25 19:03:42 1702 Initial revision (published)