1 / 2
Apr 2009

This code works fine in my system however when i try to submit gives compilation error. I know this wont be AC because i am taking O(n^2) however i just wanted to warm up with syntactical details before giving a proper shot.
Can someone please help.

#include<iostream>
#include<vector>
#include<list>
#include<queue>
#include<algorithm>
#include<iterator>
#include<string>
#include<map>
#include<cmath>
#include<cctype>
#include<cstdio>
#include<deque>
#include<stack>
#include<numeric>
#include<iterator>
using namespace std;
#define FOR(i,n) for ( int i=0 ; i<n ; i++ )
#define F(i,n) for( int i=1 ; i<=n ; i++ )
#define Fi(i,j,n) for( int i=j ; i<=n ; i++ )
#define p_b(a) push_back(a)
#define LL long long
int main() {
	long int n;
	cin >> n;
	vector<int> hr(n);
	vector<int> or(n);
	FOR(i,n) {
		cin >> hr[i] >> or[i];
	}
	FOR(i,n) {
		int ctr=0;
		FOR(j,n) {
			if(hr[j]<=hr[i] && or[j]<=or[i] && i!=j)
				ctr++;
		}
		cout << ctr << endl;
	}
	return 0;
}

And the error i am getting is :
/sources/tested.cpp: In function 'int main()':
/sources/tested.cpp:17: error: expected unqualified-id before '||' token
/sources/tested.cpp:19: error: expected primary-expression before '||' token
/sources/tested.cpp:19: error: expected primary-expression before '[' token
/sources/tested.cpp:24: error: expected primary-expression before '||' token
/sources/tested.cpp:24: error: expected primary-expression before '[' token
/sources/tested.cpp:24: error: expected primary-expression before '||' token
/sources/tested.cpp:24: error: expected primary-expression before '[' token

Please help me open_mouth

  • created

    Apr '09
  • last reply

    Apr '09
  • 1

    reply

  • 218

    views

  • 2

    users

It appears that g++ converts "or" to "||". Make sure you're using gcc or g++ and not some other c system, as this is what SPOJ uses.

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 34 26d

Want to read more? Browse other topics in C and C++ or view latest topics.