Problem in Subtask 2 of this problem .

Правка en1, от harrypotter0, 2017-04-07 14:39:18

Hi guys , I have been trying to pass this test case But i don't know why the time limit gets exceeded time and again . Can anyone find the error or at least provide a hint (how to proceed for this solution ) ?

Problem

Result ::

My submission ::::

/*
Hey , this one is mine ..
make a new one for yourself
             ---->>AKASH KANDPAL
             */
using namespace std;
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <locale>
#include <ctype.h>
#include <string.h>
#include <typeinfo>
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#define st string
#define ld long double
#define mod 1000000007
typedef long long int ll;
typedef pair < int , int > pii;
typedef vector <int> vi;
typedef vector <char> vc;
#define eps 1e-8
#define PI 3.141592653589793
#define ld long double
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
ll INF = 1e18;
const int N = 600331;
#define MOD 1e9+7

/////////////////////////////////////////////////////
vector<int> comp;
int colored[N];
vi g[N];
void dfs(int v)
{
	comp.push_back(v);
	colored[v]=1;
	for (ll i=0;i<g[v].size();i++)
	{
		ll to=g[v][i];
		if (colored[to])
			continue;
		dfs(to);
	}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
ll lcm(ll a,ll b)
{
    ll m,n;
    m=a;
    n=b;
    while(m!=n)
    {
	if(m < n)
	m=m+a;
	else
    n=n+b;
    }
    return m;
}
////////////////////////////////////////////////////////////////////////

void cal()
{
  string week[]={"sun","mon","tue","wed","thu","fri","sat"};
  ll year,days;
  cin>>year;
  days = 365*year + (year-1)/4 - (year-1)/100 + (year-1)/400 ;
  cout<<week[days%7]<<endl;
}
  ////////////////////////////////////////////////////////////////////////////
ll palin(ll x)
  {
  ll t=x,y=0;
  while(t>0)
  {
  ll rem =t%10;
  y=y*10+rem;
  t/=10;
  }
  if(x==y)
  return 1;
  else
  return 0;
  }
////////////////////////////////////////////////////////////////////////////
/*for(i=0;i<n;i++)
v.pb(i+1);f trgf  bvb gbnnnnnn             m,\ n b  cbbbbb  hgbn jyu  gbvv m,;hhjyyuu
for(i=0;i<k;i++)
{
cin>>a;
a=a%v.size();
for(j=0;j<a;j++)
rotate(v.begin(),v.begin()+1,v.end());
cout<<v[0]<<" ";
v.erase(v.begin());
*/
///////////////////////////////////////////////////////////////////////////
bool f(char ch1,char ch2){
	if(tolower(ch1)!=tolower(ch2)){
		return tolower(ch1)<tolower(ch2);
	}
	return ch1<ch2;
}
////////////////////////////////////////////////////////////////////////////
   /* double b = 2.0459332;
    stringstream ss;
    ss << fixed << setprecision(3) << b;
    string v;
    ss >> v; // v will be "2.046"
*/
///////////////////////////////////////////////////////////////////////////
int main(){
    //ios :: sync_with_stdio(0); cin.tie(0);
    //cout << (fixed) << setprecision(10);
ll t,mini=1e9,maxi=-1e9;
ll i,e,f=0,c=0,j,m,a1,p,pa,dp[201201],a[501501]={0},n,n1,ans=0,k;
//st s1[205],s2[205];
//vi v;
//map<int, int> mp;
//getline(cin,s);
//memset(dp , -1 , sizeof(dp));
//sort(s.begin(),s.end(),f);
//fill(dp+1,dp+4005,-1e9);
cin>>t;
while(t--)
{
cin>>n1>>k;
n1;f=0;
while(n1--)
{
cin>>p;
while(p--)
{
cin>>pa;
a[pa]++;
}
for(ll l=1;l<=k;l++)
{
if(a[l]==0)
{f=0;
break;}
else
{f=1;}}
if(f==1 && n1==0)
{cout<<"all"<<endl;//for(e=1;e<=k;e++)cout<<a[e]<<endl;
}
if(f==1 && n1!=0)
{cout<<"some"<<endl;//for(e=1;e<=k;e++)cout<<a[e]<<endl;
//f=0;
while(n1--){
cin>>p;
while(p--)
{
cin>>pa;
}}break;}
if(f==0 && n1==0)
{cout<<"sad"<<endl;
//for(e=1;e<=k;e++)cout<<a[e]<<endl;
}
}
for(ll i=1;i<=k;i++)
a[i]=0;
}
return 0;
}

Теги codechef long

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский harrypotter0 2017-04-07 16:25:26 426
en1 Английский harrypotter0 2017-04-07 14:39:18 4166 Initial revision (published)