QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54686#4190. Grid DeliverySa3tElSefr#WA 2ms3636kbC++1.6kb2022-10-10 04:22:422022-10-10 04:22:43

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-10 04:22:43]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3636kb
  • [2022-10-10 04:22:42]
  • 提交

answer

/// tban lecodes el bosta2
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


#define pb push_back
#define F first
#define S second
#define f(i, a, b)  for(int i = a; i < b; i++)
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x,y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll

using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;
const int N = 2e5+5, LG = 18, MOD = 1e9+7;
const long double PI = acos(-1);
const long double EPS = 1e-7;

const string TARGET = "WALDO";

bool check(ll x) {return x & (x-1);}

void doWork() {

    int n, m;
    cin >> n >> m;
    vector<ii> customers;
    set<ii> st;

    f(i,0,n)
    f(j,0,m) {
        char c;
        cin >> c;
        if(c == 'C') {
            customers.pb({i, j});
        }
    }

    sort(all(customers), [&](ii a, ii b) {
        if((a.F+a.S) == (b.F+b.S)) return a.S < b.S;
       return (a.F+a.S) < (b.F+b.S);
    });

    for(auto p : customers) {
        auto it = st.lower_bound({p.F,p.S});
        if(it!=st.begin()&&prev(it)->S <= p.S)st.erase(prev(it));
        st.insert(p);
    }

    cout << st.size() << '\n';

}
int32_t main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE

    int t = 1;
//    cin >> t;
    while (t--) {
        doWork();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3568kb

input:

4 4
__C_
C_C_
_C_C
_CCC

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

4 6
CC____
_CCC__
___C_C
C__CCC

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3628kb

input:

3 5
CC__C
_C_CC
CCCCC

output:

3

result:

ok single line: '3'

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3564kb

input:

4 4
__C_
CCCC
___C
_C_C

output:

3

result:

wrong answer 1st lines differ - expected: '2', found: '3'