답안 #390467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
390467 2021-04-16T06:18:41 Z Karliver Type Printer (IOI08_printer) C++14
10 / 100
86 ms 27556 KB

#include <bits/stdc++.h>
#include <fstream>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(20) << (x)
#define all(v) (v).begin(), (v).end()
using namespace  std;
#define forn(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
int mod = (ll)1e9 + 7;
#define PI acos(-1)
typedef pair<int, int> pairs;
typedef complex<ll> G;
const int INF = 1e9 + 1;
const int N = 1e6 + 1;
const double eps = 1e-3;

template <typename XPAX>
void ckma(XPAX &x, XPAX y) {
    x = (x < y ? y : x);
}
template <typename XPAX>
void ckmi(XPAX &x, XPAX y) {
    x = (x > y ? y : x);
}


ll power(ll a, ll b){
    if(!b)
        return 1;
    ll c=power(a,b/2);
    c=(1LL*c*c);
    if(b%2)
        c=(1LL*c*a);
    return c;
}


int mul(int a, int b) {
    return a * 1ll * b % mod;
}
int add(int a, int b) {
    int s = (a+b);
    if (s>=mod) s-=mod;
    return s;
}

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod;
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};
const ll MOD = 1e9 + 7;
using Mint = modint<MOD>;
struct FenwickTree {
    vector<int> bit;  // binary indexed tree
    int n;

    FenwickTree(int n) {
        this->n = n;
        bit.assign(n, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    int sum(int r) {
        int ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    int sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

template<class T>
struct Combination{
	vector<T> fact,factinv;
	Combination(int n) : fact(n + 1),factinv(n + 1){
		fact[0] = 1;
		for(int i = 1;i <= n;i++) fact[i] = fact[i - 1] * T(i);
		factinv[n] = ~fact[n];
		for(int i = n;i >= 1;i--) factinv[i - 1] = factinv[i] * T(i);
	}
	T nCr(int n,int r){
		if(n < 0 || r < 0 || n < r) return 0;
		return fact[n]  * factinv[r] *  factinv[n - r];
	}
	T factorial(int x) {
        if(x < 0)return 0;
        return fact[x];
	}
};

void done() {

    int x, h, y ,c;
    cin >> x >> h >> y >> c;
    int d = x + y / 2;
    int tot = h * d;
    if(tot > c)cout << "NO\n";
    else cout << "YES\n";




}



void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    forn(i, n) {
        cin >> a[i];
    }
    vector<int> b(n);
    forn(i, n)cin >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int ans = 0;
    forn(i, n) {
        ckma(ans, a[n - i - 1] + b[i]);
        ckma(ans, b[n - i - 1] + a[i]);
    }
    cout << ans << '\n';

}

void emer() {

    // start from here
    //
    //
}
void another() {

    struct node {
        vector<int> to;
        int cnt;
        node() {
            to.assign(27, -1);

            cnt = 0;
        }
    };
    int n;
    cin >> n;
    vector<node> ls;
    ls.push_back(node());
    auto add = [&](string s) {
        int now = 0;
        for(int i = 0;i < s.size();++i) {
            if(ls[now].to[s[i] - 'a'] == -1) {
                ls[now].to[s[i] - 'a'] = (int)ls.size();
                ls.push_back(node());
            }
            now = ls[now].to[s[i] - 'a'];
        }
        ls[now].cnt++;

    };
    auto cmp = [&](string t, string p) {
        return (t.size() < p.size());
    };
    vector<string> S(n);
    forn(i, n) cin >> S[i];
    sort(S.begin(), S.end(), cmp);

    forn(i, n)add(S[i]);
    vector<char> ans;
    function<void(int)> dfs = [&](int v) {
        vector<pairs> go;
        forn(i, 26) {
            if(ls[v].to[i] != -1) {
                go.push_back({ls[v].to[i], i});
            }
        }
        sort(go.begin(), go.end());
        forn(i, go.size()) {
            ans.push_back(char('a' + go[i].second));
            dfs(go[i].first);
        }
        forn(d, ls[v].cnt)ans.push_back('P');
        ans.push_back('-');
    };
    dfs(0);
    while(ans.back() == '-') ans.pop_back();
    cout << ans.size() << '\n';
    for(auto c : ans)cout << c << '\n';

}
void test_case() {
    int t;
    cin >> t;
    forn(p, t) {

        //cout << "Case #" << p + 1 << ": ";
        done();
    }
}
int main() {



    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    another();
    // 5 4 3 2 1



}

Compilation message

printer.cpp: In lambda function:
printer.cpp:220:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  220 |         for(int i = 0;i < s.size();++i) {
      |                       ~~^~~~~~~~~~
printer.cpp: In lambda function:
printer.cpp:8:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define forn(i,n) for (int i = 0; i < (n); ++i)
      |                                     ^
printer.cpp:247:9: note: in expansion of macro 'forn'
  247 |         forn(i, go.size()) {
      |         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 4544 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 11172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 27556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 73 ms 21880 KB Output isn't correct
2 Halted 0 ms 0 KB -