結果
問題 | No.709 優勝可能性 |
ユーザー |
|
提出日時 | 2018-12-02 01:10:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 133 ms / 3,500 ms |
コード長 | 3,173 bytes |
コンパイル時間 | 1,631 ms |
コンパイル使用メモリ | 172,236 KB |
実行使用メモリ | 12,392 KB |
最終ジャッジ日時 | 2024-06-27 05:07:48 |
合計ジャッジ時間 | 4,146 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include "bits/stdc++.h" // {{{using namespace std; typedef long long ll; typedef pair<int,int> pii;#define val const auto#define eb emplace_back#define emp emplace#define fi first#define se second#define outl(x) cout << (x) << '\n'#define reps(i,s,n) for(int i=(s); i < (int)(n); ++i)#define rep(i,n) reps(i,0,n)#define repr(i,h,l) for(int i=(h); i >= (int)(l); --i)#define ALL(x) begin(x), end(x)#define TMPLT(T,U) template<class T, class U>#define ten(p) ((long long)(1e##p))#define FILL(a,v) memset((a), (v), sizeof(a))#ifdef DEBUG#define debug(...) fprintf(stderr, __VA_ARGS__)#define show(x) clog << #x << " \t\t= " << (x) << '\n'#define show2(x,y) clog << '(' << #x << ',' << #y << ")\t\t= " << '(' << (x) << "\t, " << (y) << ")\n"#define LN() fputs("\n--------------------------------\n", stderr)#else#define debug(...)#define show(x)#define show2(x,y)#define LN()#endif#define def(op) inline bool operator op (const T &that) const { return comp(that) op 0; }template<class T> struct Ordered{ virtual int comp(const T &that) const = 0; def(==); def(!=); def(<); def(<=); def(>); def(>=); };#undef defnamespace {TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y){ return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }TMPLT(T,U) inline bool chmax(T &a, const U &b){return b>a ? a=b,1 : 0;}TMPLT(T,U) inline bool chmin(T &a, const U &b){return b<a ? a=b,1 : 0;}TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }template<class Itr> string mkString(Itr begin, Itr end, const char *sp = " ") {static ostringstream oss; oss.str("");for(Itr i=begin; i != end; ++i) { if(i != begin)oss << sp; oss << *i; }return oss.str();}constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;// }}}constexpr int MX = ten(5) + 10;struct Stack{int idx = 0;vector<int> buf;Stack(): buf(MX) {}void push(int x){ buf[idx++] = x; }int pop() { return buf[--idx]; }int top() { return buf[idx-1]; }bool empty() { return idx <= 0; }};void _main(const vector<char*> &args){int N, M;static int r[MX][11];static int cnt[MX] = {};cin >> N >> M;reps(i, 1, N+1) rep(j, M) cin >> r[i][j];Stack tops[11];rep(i, M) {r[0][i] = -1;tops[i].push(0);}cnt[0] = M;int ans = 1;for (int i = 1; i <= N; ++i) {rep(j, M) {val R = r[i][j];Stack &top = tops[j];if (R > r[top.top()][j]) {while( !top.empty() ){val idx = top.pop();--cnt[idx];if (cnt[idx] <= 0) {cnt[idx] = 0;--ans;}}top.push(i);++cnt[i];}else if (R == r[top.top()][j]) {top.push(i);++cnt[i];}}if (cnt[i] > 0) {++ans;}outl(ans);}}} // {{{signed main(signed argc, char *argv[]) {#ifndef DEBUGios::sync_with_stdio(false); cin.tie(nullptr);#endifcout << fixed << setprecision(9); _main(vector<char*>(argv, argv+argc)); return 0;} // }}}