CODE FESTIVAL 2016 qual A

Submission #1421131

Source codeソースコード

#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<random>
#include<unordered_set>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const int big=1e9+10;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(b==0){return a;}return gcd(b,a%b);}//a>b
llint lcm(llint a,llint b){return (a/gcd(max(a,b),min(a,b)))*b;}
int main(void){
	int n,m,q,i,j,zyu=1,nai=0;cin>>n>>m>>q;
	vector<int>ban(q);//入力 番号
	vector<deque<int>>numlis(m+1);//どこに番号があるのだろう?
	multiset<int>las;//最後に番号入れたのいつ?
	vector<bool>mita(m+1);
	for(i=0;i<n;i++){las.ins(big);}
	for(i=0;i<q;i++){
		int in;cin>>in;
		ban[i]=in;
		numlis[in].puf(i);
	}
	for(i=q-1;i>=0;i--){
		int no=ban[i];
		if(mita[no]){continue;}//skipped
		bool mincan=false;
		while(mita[zyu]){zyu++;}
		mita[no]=true;
		mincan=(zyu==no);
		vector<int>iti;
		for(j=0;j<n;j++){
			if(j>=numlis[no].size()){break;}
			auto it=las.lower_bound(numlis[no][j]);
			if(it==las.end()){break;}
			iti.pub(numlis[no][j]);
			las.erase(it);
		}
		if(j<n&&(!mincan)){cout<<"No"<<endl;return 0;}
		for(;j<n-nai;j++){
			auto it=las.lower_bound(-1);
			iti.pub(-999);
			las.erase(it);
			nai++;
		}
		while(iti.size()!=0){las.ins(iti.back());iti.pob();}
		//cout<<endl<<"de i="<<i;
		//for(auto it=las.begin();it!=las.end();it++){cout<<" "<<(*it);}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Submission

Task問題 E - LRU パズル / LRU Puzzle
User nameユーザ名 WA_TLE
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1983 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_00.txt,0_01.txt,0_02.txt,0_03.txt
All 0 / 1200 0_00.txt,0_01.txt,0_02.txt,0_03.txt,1_00.txt,1_01.txt,1_02.txt,1_03.txt,1_04.txt,1_05.txt,1_06.txt,1_07.txt,1_08.txt,1_09.txt,1_10.txt,1_11.txt,1_12.txt,1_13.txt,1_14.txt,1_15.txt,1_16.txt,1_17.txt,1_18.txt,1_19.txt,1_20.txt,1_21.txt,1_22.txt,1_23.txt,1_24.txt,1_25.txt,1_26.txt,1_27.txt,1_28.txt,1_29.txt,1_30.txt,1_31.txt,1_32.txt,1_33.txt,1_34.txt,1_35.txt,1_36.txt,1_37.txt,1_38.txt,1_39.txt,1_40.txt,1_41.txt,1_42.txt,1_43.txt,1_44.txt,1_45.txt,1_46.txt,1_47.txt,1_48.txt,1_49.txt,1_50.txt,1_51.txt,1_52.txt,1_53.txt,1_54.txt,1_55.txt,1_56.txt,1_57.txt,1_58.txt,1_59.txt,1_60.txt,1_61.txt,1_62.txt,1_63.txt,1_64.txt,1_65.txt,1_66.txt,1_67.txt,1_68.txt,1_69.txt,1_70.txt,1_71.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
0_03.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt AC 104 ms 73472 KB
1_03.txt AC 106 ms 73472 KB
1_04.txt AC 105 ms 73472 KB
1_05.txt AC 88 ms 72960 KB
1_06.txt AC 190 ms 124288 KB
1_07.txt AC 189 ms 124288 KB
1_08.txt AC 192 ms 124288 KB
1_09.txt AC 192 ms 124288 KB
1_10.txt AC 87 ms 60032 KB
1_11.txt AC 88 ms 60032 KB
1_12.txt AC 83 ms 60032 KB
1_13.txt AC 76 ms 60032 KB
1_14.txt AC 85 ms 60032 KB
1_15.txt AC 82 ms 60032 KB
1_16.txt AC 83 ms 60032 KB
1_17.txt AC 73 ms 60032 KB
1_18.txt WA
1_19.txt AC 86 ms 65408 KB
1_20.txt WA
1_21.txt AC 125 ms 115456 KB
1_22.txt WA
1_23.txt AC 93 ms 78080 KB
1_24.txt WA
1_25.txt AC 92 ms 76160 KB
1_26.txt WA
1_27.txt AC 19 ms 1152 KB
1_28.txt WA
1_29.txt AC 28 ms 3840 KB
1_30.txt WA
1_31.txt AC 56 ms 50944 KB
1_32.txt WA
1_33.txt AC 62 ms 52480 KB
1_34.txt WA
1_35.txt AC 73 ms 54016 KB
1_36.txt WA
1_37.txt AC 71 ms 49408 KB
1_38.txt WA
1_39.txt AC 100 ms 93184 KB
1_40.txt WA
1_41.txt AC 119 ms 109312 KB
1_42.txt WA
1_43.txt AC 22 ms 1408 KB
1_44.txt WA
1_45.txt AC 22 ms 1280 KB
1_46.txt WA
1_47.txt AC 41 ms 24320 KB
1_48.txt WA
1_49.txt AC 64 ms 58368 KB
1_50.txt WA
1_51.txt AC 22 ms 2048 KB
1_52.txt AC 36 ms 10368 KB
1_53.txt AC 27 ms 4352 KB
1_54.txt AC 64 ms 57472 KB
1_55.txt AC 37 ms 25728 KB
1_56.txt AC 77 ms 74752 KB
1_57.txt AC 68 ms 60544 KB
1_58.txt AC 19 ms 1152 KB
1_59.txt AC 20 ms 1152 KB
1_60.txt AC 20 ms 1152 KB
1_61.txt AC 20 ms 1152 KB
1_62.txt WA
1_63.txt AC 57 ms 66688 KB
1_64.txt AC 32 ms 19328 KB
1_65.txt AC 62 ms 53376 KB
1_66.txt AC 81 ms 6272 KB
1_67.txt AC 43 ms 5760 KB
1_68.txt AC 79 ms 6272 KB
1_69.txt AC 44 ms 5760 KB
1_70.txt AC 116 ms 69504 KB
1_71.txt AC 87 ms 55936 KB