답안 #170172

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170172 2019-12-24T07:02:10 Z Retro3014 Languages (IOI10_languages) C++17
96 / 100
6394 ms 4760 KB
#include <stdlib.h>
#include <stdio.h>
#include "grader.h"
#include "lang.h"
#include <bits/stdc++.h>

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define test 1
#define TEST if(test)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 10000;
const int MAX_K = 70000;

#define SZ 100
#define LAN 56
int idx = 0;

int lan[MAX_N+10];
map<ll, int> mp;
vector<ll> v[LAN+1];
int cnt[MAX_K+1];

vector<ll> vt;
ll mx;
int c1;



int space = 0;


void add(ll x){
	vt.pb(x);
}


void excerpt(int *E) {
	idx++;
	if(idx<=3){
		for(int i=0; i<SZ; i++){
			cnt[E[i]]++;
		}
		for(int i=0; i<MAX_K; i++){
			if(cnt[i]>cnt[space])	space = i;
		}
	}
	for(int i=0; i<SZ; i++){
		ll t = (ll)E[i];
		add(t);
		for(int j=1; j<3; j++){
			if(i+j>=SZ)	break;
			t = (t<<16LL)+(ll)E[i+j];
			add(t);
		}/*
		if(E[i]==space || E[i+1]==space || E[i+2]==space)	continue;
		vt.pb((((ll)E[i])<<32LL)+(((ll)E[i+1])<<16LL)+(ll)E[i+2]);*/
	}
	sort(vt.begin(), vt.end());
	vt.erase(unique(vt.begin(), vt.end()), vt.end());
	mx = 0; c1 = 0;
	for(int j=0; j<LAN; j++){
		if(v[j].empty())	continue;
		int c = 0;
		int k = 0;
		for(int i=0; i<vt.size(); i++){
			while(k<v[j].size()-1 && v[j][k]<vt[i]){
				k++;
			}
			c+=(v[j][k]==vt[i]);
		}
		if(c>c1){
			c1 = c; mx = j;
		}
	}
	int ask = mx;
	lan[idx] = language(ask);
	while(!vt.empty()){
		v[lan[idx]].pb(vt.back()); vt.pop_back();
	}
	sort(v[lan[idx]].begin(), v[lan[idx]].end());
	v[lan[idx]].erase(unique(v[lan[idx]].begin(), v[lan[idx]].end()), v[lan[idx]].end());
	//cout<<idx<<" "<<mx<<" "<<ask<<" "<<lan[idx]<<endl;
}

Compilation message

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:82:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<vt.size(); i++){
                ~^~~~~~~~~~
lang.cpp:83:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(k<v[j].size()-1 && v[j][k]<vt[i]){
          ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6240 ms 4760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 6394 ms 4744 KB Output is partially correct - 87.74%