답안 #1036048

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036048 2024-07-27T03:01:46 Z vjudge1 Med (COCI22_med) C++17
50 / 50
39 ms 552 KB
#warning Check FastIO
#ifdef ONLINE_JUDGE
    #pragma GCC optimize("Ofast")
    #pragma GCC target("avx,avx2,fma")
#endif
#include <iostream>
#include <algorithm>
#include <climits>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <random>
#include <chrono>
#include <iomanip>
#include <vector>
#include <fstream>
using namespace std;
#define vll vector<ll>
#define sll set<ll>
#define vstr vector<string>
#define ll long long
#define ld long double
#define supra main
#define pb push_back
#define add insert
#define rall(x) rbegin(x),rend(x)
#define all(x) (x).begin(),(x).end()
#define I ios_base::sync_with_stdio(false);
#define Hear cin.tie(NULL);
#define Shots cout.tie(NULL);
#define Ratatatata
#define bits_on(a) (__builtin_popcountll(a))
#define mx_pw2(a) (__builtin_ctzll(a))
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());  
#define SHUFFLE(v) shuffle(all(v), RNG); 
const ll inf=LLONG_MAX;
void input(vll& a)
{
    for(auto& i:a)
        cin>>i;
}
void pyn(bool a)
{
    cout<<(a?"YES":"NO")<<endl;
}
ll powmod(ll a,ll b,ll modulo)
{
  if(b==0){
    return 1;
  }
  ll temp=powmod(a,b/2,modulo);
  if(b%2==0){
    return (temp*temp)%modulo;
  }
  else{
    return (a*((temp*temp)%modulo))%modulo;
  }
}

bool Prime(ll n){
    for (ll i = 2; i*i <= n; i++)
        if (n % i == 0)
            return false;
    return (n>1);
}
bool kmp(pair<ll,string>& a,pair<ll,string>& b)
{
    return (a.first<b.first or (a.first==b.first and a.second>b.second));
}
void solve()
{
    ll n;
    cin>>n;
    vector<pair<ll,string>> a;
    vector<string> og;
    map<string,int> ind;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        ind[s]=i;
        og.pb(s);
        ll sp=0;
        for(int j=0;j<5;j++)
        {
            ll v;
            cin>>v;
            sp+=v;
        }
        a.pb({sp,s});
    }
    sort(all(a),kmp);
    auto b=a;
    vector<pair<ll,ll>> ans(n);
    // cout<<"Values\n";
    // for(int i=0;i<n;i++)
    // {
    //     cout<<a[i].first<<' '<<a[i].second<<endl;
    // }
    // cout<<endl;
    for(int i=0;i<n;i++)
    {
        ans[ind[a[i].second]]={n-i,n-i};
        b=a;
        b[i].first+=500;
        sort(all(b),kmp);
        // cout<<"new\n";
        for(ll j=0;j<n;j++)
        {
            // cout<<b[j].first<<' ' <<b[j].second<<endl;
            ll k=ind[b[j].second];
            ans[k]={min(ans[k].first,n-j),max(ans[k].second,n-j)};
        }
        // cout<<endl;;
        b=a;
        b[i].first-=500;
        sort(all(b),kmp);
        // cout<<"new\n";
        for(ll j=0;j<n;j++)
        {
            // cout<<b[j].first<<' ' <<b[j].second<<endl;
            int k=ind[b[j].second];
            ans[k]={min(ans[k].first,n-j),max(ans[k].second,n-j)};
        }
        // cout<<endl;;
    }
    for(int i=0;i<n;i++)
    {
        cout<<ans[i].first<<' '<<ans[i].second<<endl;
    }
}
int supra(){
    I Hear Shots Ratatatata
    ll tqwertyuiop=1;
    for(int tp=1;tp<=tqwertyuiop;tp++)
    {
        // cout<<"Case #"<<tp<<": ";
        solve();
    }
    return 0;
}
/*
Bro use only in a emergency 
this is kind of hacking
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
*/

Compilation message

Main.cpp:1:2: warning: #warning Check FastIO [-Wcpp]
    1 | #warning Check FastIO
      |  ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 16 ms 348 KB Output is correct
6 Correct 33 ms 348 KB Output is correct
7 Correct 20 ms 344 KB Output is correct
8 Correct 39 ms 552 KB Output is correct
9 Correct 12 ms 348 KB Output is correct