Submission #170177

# Submission time Handle Problem Language Result Execution time Memory
170177 2019-12-24T07:09:15 Z Retro3014 Languages (IOI10_languages) C++17
82 / 100
1446 ms 1984 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);
}

vector<int> vv;

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<2; 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);
	int l = lan[idx];
	for(int i=0; i<v[l].size(); i++){
		vv.pb(v[l][i]);
	}
	while(!v[l].empty())	v[l].pop_back();
	int i1 = 0, i2 = 0;
	while(i1<vv.size() || i2<vt.size()){
		if(i1==vv.size()){
			v[l].pb(vt[i2++]);
		}else if(i2==vt.size()){
			v[l].pb(vv[i1++]);
		}else{
			if(vv[i1]<vt[i2]){
				v[l].pb(vv[i1++]);
			}else if(vv[i1]>vt[i2]){
				v[l].pb(vt[i2++]);
			}else{
				v[l].pb(vv[i1++]); i2++;
			}
		}
	}
	while(!vt.empty())	vt.pop_back();
	while(!vv.empty())	vv.pop_back();
	//cout<<idx<<" "<<mx<<" "<<ask<<" "<<lan[idx]<<endl;
}

Compilation message

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:83:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<vt.size(); i++){
                ~^~~~~~~~~~
lang.cpp:84:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(k<v[j].size()-1 && v[j][k]<vt[i]){
          ~^~~~~~~~~~~~~~
lang.cpp:96:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<v[l].size(); i++){
               ~^~~~~~~~~~~~
lang.cpp:101:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(i1<vv.size() || i2<vt.size()){
        ~~^~~~~~~~~~
lang.cpp:101:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(i1<vv.size() || i2<vt.size()){
                        ~~^~~~~~~~~~
lang.cpp:102:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i1==vv.size()){
      ~~^~~~~~~~~~~
lang.cpp:104:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   }else if(i2==vt.size()){
            ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1446 ms 1804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 1444 ms 1984 KB Output is partially correct - 75.41%