hmm
Posted: Tue Mar 28, 2006 1:37 am
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 Online Judge board
https://onlinejudge.org/board/
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.shahriar_manzoor wrote: In case of LIS two codes can be same for various reasons.
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;
}
};
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;
}
};