【LGR-196-Div.4】洛谷入门赛 #26

https://www.luogu.com.cn/contest/188303

B4017 [语言月赛 202408] 相识于 2016

// Problem: B4017 [语言月赛 202408] 相识于 2016
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/B4017
// Memory Limit: 512 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll x, y;
  cin >> x >> y;
  cout << (x - 2016) * 12 + (y - 8) + 1;
  return 0;
}

B4018 [语言月赛 202408] 游戏与共同语言

// Problem: B4018 [语言月赛 202408] 游戏与共同语言
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/B4018
// Memory Limit: 512 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll w_a, c_a, t_a, w_b, c_b, t_b;
  cin >> w_a >> c_a >> t_a >> w_b >> c_b >> t_b;
  if (w_a == w_b) {
    if (c_a == c_b) {
      if (t_a == t_b) {
      } else {
        cout << (t_a < t_b ? "A" : "B");
        return 0;
      }
    } else {
      cout << (c_a < c_b ? "B" : "A");
      return 0;
    }
  } else {
    cout << (w_a < w_b ? "B" : "A");
    return 0;
  }
}

B4019 [语言月赛 202408] 皆与生物有缘

// Problem: B4019 [语言月赛 202408] 皆与生物有缘
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/B4019
// Memory Limit: 512 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    ll m;
    cin >> m;
    sum += m;
    cin >> m;
    sum += m;
  }
  cout << (sum / 2) + (sum % 2);
  return 0;
}

B4020 [语言月赛 202408] 两座城市的 543 千米

// Problem: B4020 [语言月赛 202408] 两座城市的 543 千米
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/B4020
// Memory Limit: 512 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, M, a, b, count = 0;
  cin >> N >> M >> a >> b;
  for (int i = 0; i < M; i++) {
    ll l, a_1 = -1, b_1 = -1;
    cin >> l;
    for (int j = 0; j < l; j++) {
      ll num;
      cin >> num;
      if (num == a) {
        a_1 = j;
      }
      if (num == b) {
        b_1 = j;
      }
    }
    if (a_1 < b_1 && a_1 != -1 && b_1 != -1) {
      count++;
    }
  }
  cout << count;
  return 0;
}

B4021 [语言月赛 202408] 于抑郁中支持

// Problem: B4021 [语言月赛 202408] 于抑郁中支持
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/B4021
// Memory Limit: 512 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll x[100001];
int main() {
  ll n, t, count = 0;
  cin >> n >> t;
  ll n_1 = n;
  for (int i = 0; i < n; i++) {
    ll num;
    cin >> num;
    num = num % int(pow(10, t));
    x[num]++;
  }
  for (int i = 0; i < int(pow(10, t)); i++) {
    if (x[i]) {
      count++;
      n_1 -= x[i];
    }
  }
  cout << count + n_1;
  return 0;
}

B4022 [语言月赛 202408] 蓝色的网易云

// Problem: B4022 [语言月赛 202408] 蓝色的网易云
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/B4022
// Memory Limit: 512 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll music[1001][1001];
ll count_1[1001];
int main() {
  ll n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    ll c_1;
    cin >> c_1;
    music[c_1][count_1[c_1]++] = i;
  }
  for (int i = 0; i < n / m; i++) {
    for (int j = 1; j <= m; j++) {
      if (music[j][i]) {
        cout << music[j][i] << "\n";
      }
    }
  }
  return 0;
}

B4023 [语言月赛 202408] 因友情而终结

// Problem: B4023 [语言月赛 202408] 因友情而终结
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/B4023
// Memory Limit: 512 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string s, c = "friend";
int main() {
  while (cin >> s) {
    ll index = 0;
    ll sum = 0;
    while ((index = s.find(c, index)) != string::npos) {
      sum++;
      s.replace(index + 5, 4, "love");
    }
    cout << sum << endl;
  }
  return 0;
}

B4024 [语言月赛 202408] 保持连接的方式

// Problem: B4024 [语言月赛 202408] 保持连接的方式
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/B4024
// Memory Limit: 512 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<vector<vector<ll> > > box(
    100, vector<vector<ll> >(100, vector<ll>(50, INT_FAST32_MAX)));
vector<vector<ll> > box_depth(100, vector<ll>(100, 1));
vector<vector<ll> > box_min(100, vector<ll>(100, 49));
vector<vector<ll> > box_min_second(100, vector<ll>(100, 49));
// ll box[101][101][51];
// ll box_depth[101][101] = {1};
// ll box_min[101][101] = {52};
int main() {
  ll n, m, k, t;
  cin >> n >> m >> k >> t;
  for (int i = 1; i <= t; i++) {
    ll a_i, x_i, y_i;
    cin >> a_i >> x_i >> y_i;
    if (box[x_i][y_i][k] != INT_FAST32_MAX) {
      cout << box[x_i][y_i][box_min[x_i][y_i]];
      box[x_i][y_i].erase(box[x_i][y_i].begin() + box_min[x_i][y_i]);
      cout << " " << k - box_min[x_i][y_i] << "\n";
      box_min[x_i][y_i] = box_min_second[x_i][y_i];
      box_depth[x_i][y_i]--;
    } else {
      cout << "-1\n";
    }
    box[x_i][y_i][box_depth[x_i][y_i]] = a_i;
    if (box[x_i][y_i][box_min[x_i][y_i]] < a_i) {
    } else {
      box_min_second[x_i][y_i] = box_min[x_i][y_i];
      box_min[x_i][y_i] = box_depth[x_i][y_i];
    }
    box_depth[x_i][y_i]++;
  }
  return 0;
}

感觉对但是没过,我死

修改版:

// Problem: B4024 [语言月赛 202408] 保持连接的方式
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/B4024
// Memory Limit: 512 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ll n, m, k, t;
  cin >> n >> m >> k >> t;

  vector<vector<vector<ll>>> box(n + 1, vector<vector<ll>>(m + 1));
  vector<vector<ll>> box_depth(n + 1, vector<ll>(m + 1, 0));

  for (int i = 1; i <= t; i++) {
    ll a_i, x_i, y_i;
    cin >> a_i >> x_i >> y_i;

    if (box_depth[x_i][y_i] == k) {
      auto it = min_element(box[x_i][y_i].begin(), box[x_i][y_i].end());
      ll min_val = *it;
      cout << min_val << " " << distance(it, box[x_i][y_i].end()) - 1 << "\n";
      box[x_i][y_i].erase(it);
      box_depth[x_i][y_i]--;
    } else {
      cout << "-1\n";
    }

    box[x_i][y_i].push_back(a_i);
    box_depth[x_i][y_i]++;
  }

  return 0;
}

为什么这个就行呢?

发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注

滚动至顶部