Page 2 of 2

hmm

Posted: Tue Mar 28, 2006 1:37 am
by shahriar_manzoor
I mean if problems were original it is more unlikely that two codes will be same by accident. In case of LIS two codes can be same for various reasons.

the two codes...

Posted: Tue Mar 28, 2006 8:12 am
by sohel
shahriar_manzoor wrote: In case of LIS two codes can be same for various reasons.
Two LIS code can be very similar. But the TC admins are also saying that there are same typograhical errors in both of our codes.

I will paste both of our codes here. Personally I can't see that much of a similarity that will make me a cheater.

My code -->

Code: Select all

#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#ifdef __GNUC__
#define int64 long long
#else
#define int64 __int64
std::ostream& operator<<(std::ostream& os, int64 i ){
	char buf[20];
	sprintf(buf,"%I64d", i );
	os << buf;
	return os;
}
#endif

struct node {
	int x, y;
};

vector<node> V;

int dp[10100];

bool cmp(const node &a, const node &b) {
	if( a.x != b.x)
		return a.x < b.x;
	return a.y < b.y;
}

bool notfitin(node &a, node &b) {
	return a.x >= b.x || a.y >= b.y;
}

class UnNestable{
public:
	int maxCount(int a, int p, int n){
		//Your code goes here...
		V.clear ();

		int rv=1, i, j;
		for( i=0; i<n; i++){
			rv = (rv*a)%p; int x=rv;
			rv = (rv*a)%p; int y=rv;
			node A;
			if( x > y) swap(x, y);
			A.x = x, A.y = y;
			V.push_back (A);
        //process this box, which has dimensions x and y

		}

		sort(V.begin(), V.end () , cmp);

		

		for(i=0;i<n;i++)
			dp[i] = 1;


		int maxi = 1;

		for(i=1;i<n;i++) {
			for(j=i-1;j>=0;j--) {
				if( V[i].x == V[i-1].x && V[i].y == V[i-1].y ) {
					dp[i] = dp[i-1] + 1;	
					maxi = maxi < dp[i] ? dp[i] : maxi;
					break;
				}
				if(  V[i].x <= V[j].x || V[i].y <= V[j].y){
					if( dp[i] < dp[j] + 1)
						dp[i] = dp[j] + 1;
					maxi = maxi < dp[i] ? dp[i] : maxi;
				}
			}
		}
			return maxi;
	}
    	
};

Tosun's Code -->

Code: Select all

#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#ifdef __GNUC__
#define int64 long long
#else
#define int64 __int64
std::ostream& operator<<(std::ostream& os, int64 i ){
	char buf[20];
	sprintf(buf,"%I64d", i );
	os << buf;
	return os;
}
#endif

struct node{
	int x, y;
};

vector<node> V;

bool cmp(const node &a, const node &b) {
	if( a.x != b.x ) return a.x < b.x;
	return a.y < b.y;
}

int dp[10010];


bool fit(node &a, node &b) {
	return (a.x < b.x) && (a.y < b.y);
}

class UnNestable{
	
public:
	


	int maxCount(int a, int p, int n){
		//Your code goes here...
		V.clear();
		int rv=1, x, y, i, j;
		for(i=0; i<n; i++){
			rv = (rv*a)%p; x=rv;
			rv = (rv*a)%p; y=rv;
			node A;
			A.x = x, A.y = y;
			V.push_back (A);
		}	

		sort(V.begin(), V.end (), cmp);
		
		for(i=0;i<n;i++) dp[i] = 0;
		dp[0] = 0;
		int maxi = 0;
		for( i=1;i<V.size ();i++) {
			for(j=i-1;j>=0;j--) {
				if( fit( V[j], V[i] ) ) {
					if( dp[i] < dp[j] + 1)
						dp[i] = dp[j] + 1;

					if(maxi < dp[i] ) maxi = dp[i];
				}
			}
		}
		return n - maxi;
    
	}
};


Posted: Tue Mar 28, 2006 8:24 am
by sohel
The header file and the comments like 'your code starts here'.. are same

but we both use this format all the time. Infact some of my other friends use this format too. So that can't be a reason.

Moreover Tosun's code was no where close to the original solution. But, just changing my cmp function by 1 character(from return a.y < b.y to return a.y > b.y) will convert my code from WA to AC.

And Tosun was unable to match a given sample.


I would again like to say that I had no collaboration with tosun. But I can't convince the TC admin.

What can I do now?

I can't write in TC forum because they have deactivated my account there. I have made some posts using shamim's account, but that doesn't look nice.

-- sohel