Submission #118244

# Submission time Handle Problem Language Result Execution time Memory
118244 2019-06-18T12:32:42 Z baluteshih Fish (IOI08_fish) C++14
0 / 100
3000 ms 39660 KB
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll INF=1e9;
ll MOD;
pll fish[500005];
vector<pll> pl[500005];
vector<pll> place;
bitset<500005> vis;
ll cnt[500005],bound[500005];

int main()
{jizz
	ll n,k,ans=0,tmp,num;
	cin >> n >> k >> MOD;
	for(int i=0;i<n;++i)
		cin >> fish[i].F >> fish[i].S;
	sort(fish,fish+n);
	for(int i=0;i<n;++i)
		pl[fish[i].S].pb(MP(fish[i].F,1));
	for(int i=1;i<=k;++i)
		place.pb(MP(pl[i].back().F,i));
	sort(ALL(place));
	for(int i=n-1;i>=0;--i)
		if(!vis[fish[i].S])
		{
			vector<pll> v;
			vis[fish[i].S]=1,tmp=1;
			for(int j=1;j<=k;++j)
				cnt[j]=0;
			for(int j=0;j<n&&fish[j].F*2<=fish[i].F;++j)
				++cnt[fish[j].S];
			for(int j=0,t=0;j<k;++j)
			{
				while(t<pl[fish[i].S].size()&&pl[fish[i].S][t].F*2<=place[j].F)
					++t;
				bound[place[j].S]=t;
			}
			for(int j=1;j<=k;++j)
				if(!vis[j])
				{
					tmp=tmp*(cnt[j]+1)%MOD;
					if(cnt[j]==0) pl[j].back().S=pl[j].back().S*bound[j]%MOD;
					else if(cnt[j]<pl[j].size())
						pl[j][cnt[j]-1].S=pl[j][cnt[j]-1].S*bound[j]%MOD;
				}
			num=1,tmp=tmp*pl[fish[i].S].back().S%MOD;
			ans=(ans+tmp)%MOD;
			for(int j=0;j<pl[fish[i].S].size()&&pl[fish[i].S][j].F*2<=fish[i].F;++j)
				tmp=tmp*pl[fish[i].S][j].S%MOD,ans=(ans+tmp)%MOD;
		}
	cout << ans << "\n";
}

Compilation message

fish.cpp: In function 'int main()':
fish.cpp:47:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(t<pl[fish[i].S].size()&&pl[fish[i].S][t].F*2<=place[j].F)
           ~^~~~~~~~~~~~~~~~~~~~~
fish.cpp:56:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      else if(cnt[j]<pl[j].size())
              ~~~~~~^~~~~~~~~~~~~
fish.cpp:61:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<pl[fish[i].S].size()&&pl[fish[i].S][j].F*2<=fish[i].F;++j)
                ~^~~~~~~~~~~~~~~~~~~~~
fish.cpp:26:19: warning: variable 'num' set but not used [-Wunused-but-set-variable]
  ll n,k,ans=0,tmp,num;
                   ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 12160 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 12160 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 12032 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 12160 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 12132 KB Output is correct
2 Incorrect 13 ms 12160 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 12160 KB Output is correct
2 Incorrect 184 ms 28060 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 12288 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 12288 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 147 ms 20188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 12372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 503 ms 24872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2392 ms 31096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 842 ms 24824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3018 ms 30272 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 3015 ms 33000 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 3022 ms 27152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3015 ms 36020 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3022 ms 36064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3048 ms 39660 KB Time limit exceeded
2 Halted 0 ms 0 KB -