답안 #776500

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
776500 2023-07-08T02:48:26 Z salmon Fish (IOI08_fish) C++14
0 / 100
1450 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
int N,M;
int mod;
int l,h;
const int sq = 707;
vector<pair<int,int>> v;
int pown[sq + 5][500100];

int main(){
	scanf(" %d",&N);
	scanf(" %d",&M);
	
	scanf(" %d",&mod);
	
	map<int,int> mep;
	set<int> one;
	map<int,int> mepu;
	set<int> oneu;
	bool visited[M + 1];
	bool usable[M + 1];
	
	for(int j = 1; j <= sq + 1; j++){
		pown[j][0] = 1;
		for(int i = 1; i <= M; i++){
			pown[j][i] = pown[j][i - 1] * j % mod;
		}
	}
	
	for(int i = 0; i <= M; i++){
		visited[i] = false;
	}
	
	for(int i = 0; i <= M; i++) usable[i] = false;
	
	for(int i = 0; i < N; i++){
		scanf(" %d",&l);
		scanf(" %d",&h);
		
		v.push_back(make_pair(l,h));
	}
	
	sort(v.begin(),v.end(),greater<pair<int,int>>());
	
	set<int> o;
	set<int> smol;
	vector<pair<int,int>> oh;
	
	for(int i = 0; i < v.size(); i++){
		if(o.find(v[i].second) == o.end()){
			oh.push_back(v[i]);
			o.insert(v[i].second);
		}
	}
	
	int it = 0;
	
	reverse(v.begin(),v.end());

	int bigans = 0;
	
	for(int i = 0; i < N; i++){
		while(it != N && v[i].first >= v[it].first * 2){
			if(usable[v[it].second]){
				if(one.find(v[it].second) != one.end() && mep.find(v[it].second) == mep.end()){
					one.erase(v[it].second);
					mep[v[it].second] = 2;
				}
				else if(mep.find(v[it].second) == mep.end()){
					one.insert(v[it].second);
				}
				else{
					mep[v[it].second]++;
				}
				
				it++;
			}
			else{
				if(oneu.find(v[it].second) != oneu.end() && mepu.find(v[it].second) == mepu.end()){
					oneu.erase(v[it].second);
					mepu[v[it].second] = 2;
				}
				else if(mepu.find(v[it].second) == mepu.end()){
					oneu.insert(v[it].second);
				}
				else{
					mepu[v[it].second]++;
				}
				
				it++;
			}
		}
		
		if(v[i] == oh.back()){
			
			if(mepu.find(oh.back().second) != mepu.end()){
				mep[oh.back().second] = mepu[oh.back().second];
			}
			else if(oneu.find(oh.back().second) != oneu.end()){
				one.insert(oh.back().second);
			}
			
			usable[oh.back().second] = true;
			
			long long int ans = pown[2][one.size()];
			
			for(pair<int,int> ii : mep){
				ans = ans * (ii.second + 1) % mod;
 			}
 			
 			bigans += ans;
 			bigans %= mod;
 			
 			
 			
 			oh.pop_back();
		}
	}
	
	printf("%d",bigans);
}
/*
5
3
700
2 2
5 1
8 3
4 1
2 3
 */

Compilation message

fish.cpp: In function 'int main()':
fish.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for(int i = 0; i < v.size(); i++){
      |                 ~~^~~~~~~~~~
fish.cpp:20:7: warning: variable 'visited' set but not used [-Wunused-but-set-variable]
   20 |  bool visited[M + 1];
      |       ^~~~~~~
fish.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf(" %d",&N);
      |  ~~~~~^~~~~~~~~~
fish.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf(" %d",&M);
      |  ~~~~~^~~~~~~~~~
fish.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf(" %d",&mod);
      |  ~~~~~^~~~~~~~~~~~
fish.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   scanf(" %d",&l);
      |   ~~~~~^~~~~~~~~~
fish.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |   scanf(" %d",&h);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 5768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 5844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 5844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 5844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5844 KB Output is correct
2 Incorrect 4 ms 5856 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5844 KB Output is correct
2 Incorrect 150 ms 10044 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6100 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 5972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 64 ms 8668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 11648 KB Output is correct
2 Correct 15 ms 8744 KB Output is correct
3 Incorrect 14 ms 10764 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 150 ms 14552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 152 ms 15576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 21124 KB Output is correct
2 Incorrect 407 ms 30160 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 941 ms 44328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1450 ms 62180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 110 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 109 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 108 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 103 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -