Submission #16513967


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <queue>
typedef long long ll;
#define rep(i,n) for(int i = 0;i<n;++i)
#define repc(bit,k,n) for (int bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;
using Graph = vector<vector<int> >;

/* next combination
 * usage:repc(bit,k,n)
 * */
inline int next_combination(int sub) {
  int x = sub & -sub, y = sub + x;
  return (((sub & ~y) / x) >> 1) | y;
}

/* uniq
 * usage:uniq(vec)
 * */
void uniq(vector<int> &vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return;
}

/* BinaryIndexedTree
 * usage:update and sum of 1~N
 * */
int N;
int bit[1000010];
void add(int a, int w) {
  for (int x = a; x <= N; x += x & -x) bit[x] += w;
}
int sum(int a) {
  int ret = 0;
  for (int x = a; x > 0; x -= x & -x) ret += bit[x];
  return ret;
}

/* DP
 * usage: chmin(dp[i],dp[i-1]+v);
 * */
const ll INF = 1LL << 60;
ll dp[100010];

template<class T> inline bool chmin(T& a, T b) {
      if (a > b) {
                a = b;
                        return true;
                            }
          return false;
}
template<class T> inline bool chmax(T& a, T b) {
      if (a < b) {
                a = b;
                        return true;
                            }
          return false;
}

int count16bit(unsigned short v) {
  unsigned short count = (v & 0x5555) + ((v >> 1) & 0x5555);
  count = (count & 0x3333) + ((count >> 2) & 0x3333);
  count = (count & 0x0f0f) + ((count >> 4) & 0x0f0f);
  return (count & 0x00ff) + ((count >> 8) & 0x00ff);
}
ll solve(ll a,ll b, ll c, const vector<vector<ll> > &company){
  repi(itr,company){
    if(((*itr)[1]<=a)&&((*itr)[2]<=b)&&((*itr)[3]<=c))return (*itr)[0];
  }
  return 0;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;cin>>n>>m;
  vector<vector<ll> >company(n);
  rep(i,n){
    ll a,b,c,w;cin>>a>>b>>c>>w;
    company[i] = {w,a,b,c};
  }
  sort(company.begin(),company.end(), [](const vector<ll> &a, const vector<ll> &b){return a[0]>b[0];});
  cout<<endl<<":"<<company[0][0]<<company[0][1]<<company[0][2]<<company[0][3]<<endl;
  rep(i,m){
    ll a,b,c;cin>>a>>b>>c;
    cout<<solve(a,b,c,company)<<endl;
  }


  return 0;
}

Submission Info

Submission Time
Task C - Optimal Recommendations
User koppepyan
Language C++ (GCC 9.2.1)
Score 0
Code Size 2445 Byte
Status WA
Exec Time 2205 ms
Memory 6772 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
WA × 22
TLE × 2
Set Name Test Cases
All 10-random-00.txt, 10-random-01.txt, 10-random-02.txt, 10-random-03.txt, 10-random-04.txt, 20-absW-00.txt, 20-absW-01.txt, 20-absW-02.txt, 20-absW-03.txt, 20-absW-04.txt, 30-balance-00.txt, 30-balance-01.txt, 30-balance-02.txt, 30-balance-03.txt, 30-balance-04.txt, 40-limit_dim-00.txt, 40-limit_dim-01.txt, 40-limit_dim-02.txt, 40-limit_dim-03.txt, 40-limit_dim-04.txt, 40-limit_dim-05.txt, 40-limit_dim-06.txt, Corner1.txt, Sample1.txt
Case Name Status Exec Time Memory
10-random-00.txt WA 137 ms 6572 KB
10-random-01.txt WA 10 ms 3508 KB
10-random-02.txt WA 77 ms 3784 KB
10-random-03.txt WA 109 ms 4496 KB
10-random-04.txt WA 39 ms 5808 KB
20-absW-00.txt TLE 2205 ms 6772 KB
20-absW-01.txt WA 6 ms 3552 KB
20-absW-02.txt WA 1950 ms 6356 KB
20-absW-03.txt TLE 2205 ms 4956 KB
20-absW-04.txt WA 405 ms 4096 KB
30-balance-00.txt WA 142 ms 6536 KB
30-balance-01.txt WA 6 ms 3648 KB
30-balance-02.txt WA 47 ms 3784 KB
30-balance-03.txt WA 65 ms 6620 KB
30-balance-04.txt WA 99 ms 3928 KB
40-limit_dim-00.txt WA 114 ms 6556 KB
40-limit_dim-01.txt WA 115 ms 6536 KB
40-limit_dim-02.txt WA 114 ms 6460 KB
40-limit_dim-03.txt WA 117 ms 6468 KB
40-limit_dim-04.txt WA 114 ms 6516 KB
40-limit_dim-05.txt WA 113 ms 6516 KB
40-limit_dim-06.txt WA 114 ms 6556 KB
Corner1.txt WA 9 ms 3448 KB
Sample1.txt WA 2 ms 3552 KB