Submission #10303385


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N; cin >> N;
    vector<pair<pii,int> > P(N);
    vector<vector<int>> ans(N, vector<int>(3));
    rep(i, 0, N){
        int r, h; cin >> r >> h;
        h--;
        P[i] = mp(mp(r,h), i);
    }
    sort(ALL(P));
    rep(i, 0, N){
        int rate = P[i].first.first;
        int h = P[i].first.second;
        int id = P[i].second;
        int res1 = 0, res2 = 0;
        res1 += lower_bound(ALL(P), mp(mp(rate, 0), 0)) - P.begin();
        if(h == 0) res1 += upper_bound(ALL(P), mp(mp(rate, 1), INF)) - lower_bound(ALL(P), mp(mp(rate, 1), 0)); 
        if(h == 1) res1 += upper_bound(ALL(P), mp(mp(rate, 2), INF)) - lower_bound(ALL(P), mp(mp(rate, 2), 0)); 
        if(h == 2) res1 += upper_bound(ALL(P), mp(mp(rate, 0), INF)) - lower_bound(ALL(P), mp(mp(rate, 0), 0)); 
        res2 = upper_bound(ALL(P), mp(mp(rate, h), INF)) - lower_bound(ALL(P), mp(mp(rate, h), 0)) - 1; 
        ans[id][0] = res1;
        ans[id][2] = res2;
        ans[id][1] = N - 1 - res1 - res2;
    }
    rep(i, 0, N){
        rep(j, 0, 3){
            if(j != 0 )cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}

Submission Info

Submission Time
Task B - AtCoderでじゃんけんを
User raoZ
Language C++14 (GCC 5.4.1)
Score 100
Code Size 4006 Byte
Status AC
Exec Time 237 ms
Memory 8704 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 31
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt AC 232 ms 8192 KB
02.txt AC 233 ms 8192 KB
03.txt AC 222 ms 8320 KB
04.txt AC 221 ms 8320 KB
05.txt AC 221 ms 8576 KB
06.txt AC 224 ms 8576 KB
07.txt AC 223 ms 8704 KB
08.txt AC 222 ms 8704 KB
09.txt AC 222 ms 8704 KB
10.txt AC 221 ms 8704 KB
11.txt AC 228 ms 8192 KB
12.txt AC 228 ms 8192 KB
13.txt AC 223 ms 8192 KB
14.txt AC 219 ms 7936 KB
15.txt AC 220 ms 7936 KB
16.txt AC 225 ms 7936 KB
17.txt AC 224 ms 8448 KB
18.txt AC 224 ms 8448 KB
19.txt AC 231 ms 8192 KB
20.txt AC 233 ms 8192 KB
21.txt AC 233 ms 8192 KB
22.txt AC 235 ms 8192 KB
23.txt AC 235 ms 8192 KB
24.txt AC 237 ms 8192 KB
25.txt AC 1 ms 256 KB
26.txt AC 1 ms 256 KB
27.txt AC 1 ms 256 KB
28.txt AC 1 ms 256 KB
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB