제출 #958000

#제출 시각아이디문제언어결과실행 시간메모리
958000vjudge1Lottery (CEOI18_lot)C++17
45 / 100
2804 ms1136 KiB

//* Nigga we hit em up like mutherfucking Tupac Shakur

#include <bits/stdc++.h>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
      
using namespace std;
using namespace __gnu_pbds;
      
template <typename T>
using oset = tree<T,null_type,less<T>, rb_tree_tag, tree_order_statistics_node_update>;
      
#define int long long
          
#define pb push_back
#define ins insert
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
  
          
using ll = long long;
using ld = long double;

#define endl '\n'

#define no cout<<"NO"<<endl
#define yes cout<<"YES"<<endl
        
#define da cout<<"DA"<<endl
#define ne cout<<"NE"<<endl
          
#define send ios::sync_with_stdio(false);
#define help cin.tie(0);
          
void solve(int T);
          
const int N = 2005;
const int M = 5e5 + 10;
const int SQRT = sqrt(N);
const int LOG = 20;
const int INF = 1e18;
const int MOD = 123456789;
const ld EPS = 1e-9;

  
//int ans;
int n, m,k, q, l, r, x, y, z, mx, mn;
  
  
          
int32_t main(){
    auto begin = chrono::high_resolution_clock::now();
    cout<<setprecision(7)<<fixed;
              
    send help;
          
    int tt = 1;
    //cin>>tt; //? Comment if no testcases
    for(int i = 1;i<=tt;i++){
        cerr<<"Case "<<i<<": "<<endl;
        solve(i);
    }
    auto end = chrono::high_resolution_clock::now();
    cerr<<"Time: "<<chrono::duration_cast<chrono::duration<double>>(end - begin).count()<<endl;
    return 0;
}

int A[N];

int ans[105][N];

void solve(int T){
    int l; 
    cin>>n>>l;

    for(int i = 0;i<n;i++)cin>>A[i];
    cin>>q;
    pair<int,int> que[q];
    for(int i = 0;i<q;i++){
        int x;
        cin>>x;
        que[i] = {x, i};
    }

    sort(que, que + q);

    //int ans[q][n];

    for(int i = 0;i+l-1<n;i++){
        deque<int> x, y;
		for (int j = i;j<i+l;j++)x.push_back(A[j]);
		for (int j = 0;j<l;j++)y.push_back(A[j]);
		int cnt = 0;
		for (int k = 0;k<l;k++) {
			if (x[k] != y[k]) cnt++;
		}
		vector<int> v;
		if (i) v.push_back(cnt);
		for (int j = l;j <n;j++) {
			y.pop_front();
			y.push_back(A[j]);
			if (j - l + 1 == i) continue;
			cnt = 0;
			for (int k = 0;k<l;k++) {
				if (x[k] != y[k]) cnt++;
			}
			v.push_back(cnt);
		}
		sort(all(v));
		int p = 0;

		for(int k = 0;k<q;k++){
			while (p < v.size() && v[p] <= que[k].first) p++;
			ans[que[k].second][i] = p;
		}
    }

    for(int i = 0;i<q;i++){
        for(int j = 0;j+l-1 < n;j++)cout<<ans[i][j]<<" ";
        cout<<endl;
    }
}   
  
  
  
//! Te molam da raboti !!

컴파일 시 표준 에러 (stderr) 메시지

lot.cpp: In function 'void solve(long long int)':
lot.cpp:116:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  116 |    while (p < v.size() && v[p] <= que[k].first) p++;
      |           ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...