提出 #76484863
ソースコード 拡げる
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <unordered_map>
#include <map>
#include <queue>
#include <unordered_set>
#include <cassert>
#include <list>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numbers>
#include <iostream>
#include <string>
#include <random>
using namespace std;
#define fori(n)for (ll i = 0; i < n; i++)
#define fo(n)for (int i = 0; i < n; i++)
#define fori1(n)for (ll i = 1; i < n + 1; i++)
#define revi1(n)for (int i = n; i >0; i--)
#define forj(n)for (ll j = 0; j < (n); j++)
#define rep(i, n)for (ll i = 0; i < (n); i++)
#define repj(i, j, n)for (ll i = j; i < (n); i++)
#define forj1(n)for (ll j = 1; j < n+1; j++)
#define revj1(n)for (ll j = n; j >=0; j--)
#define revi(n)for (int i = n-1; i >= 0; i--)
#define ll long long
#define ull unsigned ll
#define MAXN (2147483647)
#define MINN (-2147483648)
#define ffast_io ios::sync_with_stdio(false);\
cout.tie(nullptr); cin.tie(nullptr)
string svo(bool fl) {
if (fl)
return "YES";
return "NO";
}
vector<vector<ll>> multi(vector<vector<ll>> a, vector<vector<ll>> b) {
vector<vector<ll>> res(a.size(), vector<ll>(b[0].size(), 0));
fori(a.size()) {
forj(b[0].size()) {
ll temp = 0;
rep(k, b.size())temp = (temp + (a[i][k] * b[k][j]) % 1000000007l) % 1000000007;
res[i][j] = temp;
}
}
return res;
}
vector<vector<ll>> pow(const vector<vector<ll>> &mat, int powred) {
if (powred == 1) return mat;
if (powred % 2 == 1) return multi(pow(mat, powred - 1), mat);
vector<vector<ll>> temp = pow(multi(mat, mat), powred / 2);
return temp;
}
ll pow1(ll mat, ll powred) {
if (powred == 1L) return mat;
if ((powred % 2LL) == 1LL) return (pow1(mat, powred - 1LL) * mat) % 10LL;
auto temp = pow1((mat * mat) % 10LL, powred / 2LL);
return temp;
}
template<typename T>
void debug(const std::vector<T> &ttt, std::ostream &out = std::cout) {
int temp = 1;
for (auto it = ttt.begin(); it != ttt.end(); ++it, temp++) out << *it << ' ';
out << std::endl;
}
template<typename T>
void debug(const std::vector<vector<T>> &ttt, std::ostream &out = std::cout) {
for (int it = 0; it != ttt.size(); ++it) debug(ttt[it]);
}
template<typename T>
void debug(set<T> ttt, std::ostream &out = std::cout) {
for (auto t: ttt) out << t << " ";
out << endl;
}
void debug(bool k, std::ostream &out = std::cout) { if (k) out << "yes"; else out << "no"; }
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC b("sse,sse2,sse3,ssse3,sse4,abm,mmx,tune=native")
struct fw {
vector<int> bit;
int n;
fw(int n) {
this->n = n;
bit.assign(n, 0);
}
int sum(int r) {
int ret = 0;
for (; r >= 0; r = (r & (r + 1)) - 1)
ret += bit[r];
return ret;
}
void add(int idx, int delta) {
for (; idx < n; idx = idx | (idx + 1))
bit[idx] += delta;
}
};
void solve() {
int n, q;
cin >> n >> q;
fw r(q + 1), c(q + 1);
r.add(0, n);
c.add(0, n);
vector<int> rl(n + 1, 0), cl(n + 1, 0);
ll ans = 0;
fori1(q) {
int tp, x;
cin >> tp >> x;
if (tp == 1) {
ll del = c.sum(i - 1);
if (rl[x] > 0) {
del -= c.sum(rl[x] - 1);
} else {
del -= 0;
}
ans += del;
r.add(rl[x], -1);
r.add(i, 1);
rl[x] = i;
} else {
ans += r.sum(cl[x]) - r.sum(i);
c.add(cl[x], -1);
c.add(i, 1);
cl[x] = i;
}
cout << ans << "\n";
}
}
int main() {
ffast_io;
solve();
return 0;
}
提出情報
提出日時
2026-06-06 22:42:20+0900
問題
E - E-liter
ユーザ
kashapoV
言語
C++23 (GCC 15.2.0)
得点
475
コード長
4039 Byte
結果
AC
実行時間
57 ms
メモリ
8880 KiB
コンパイルエラー
./Main.cpp:97: warning: ignoring '#pragma GCC b' [-Wunknown-pragmas]
97 | #pragma GCC b("sse,sse2,sse3,ssse3,sse4,abm,mmx,tune=native")
./Main.cpp: In function 'std::vector<std::vector<long long int> > multi(std::vector<std::vector<long long int> >, std::vector<std::vector<long long int> >)':
./Main.cpp:26:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | #define fori(n)for (ll i = 0; i < n; i++)
| ^
./Main.cpp:51:5: note: in expansion of macro 'fori'
51 | fori(a.size()) {
| ^~~~
./Main.cpp:30:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | #define forj(n)for (ll j = 0; j < (n); j++)
| ~~^~~~~
./Main.cpp:52:9: note: in expansion of macro 'forj'
52 | forj(b[0].size()) {
| ^~~~
./Main.cpp:31:35: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | #define rep(i, n)for (ll i = 0; i < (n); i++)
| ^
./Main.cpp:54:13: note: in expansion of macro 'rep'
54 | rep(k, b.size())temp = (temp + (a[i][k] * b[k][j]) % 1000000007l) % 1000000007;
| ^~~
ジャッジ結果
セット名
Sample
All
得点 / 配点
0 / 0
475 / 475
結果
セット名
テストケース
Sample
sample-01.txt, sample-02.txt
All
03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, sample-01.txt, sample-02.txt
ケース名
結果
実行時間
メモリ
03.txt
AC
1 ms
3668 KiB
04.txt
AC
1 ms
3548 KiB
05.txt
AC
32 ms
5744 KiB
06.txt
AC
30 ms
5780 KiB
07.txt
AC
2 ms
5708 KiB
08.txt
AC
2 ms
5708 KiB
09.txt
AC
35 ms
8160 KiB
10.txt
AC
31 ms
8084 KiB
11.txt
AC
41 ms
8752 KiB
12.txt
AC
37 ms
8096 KiB
13.txt
AC
30 ms
5636 KiB
14.txt
AC
30 ms
5700 KiB
15.txt
AC
1 ms
3784 KiB
16.txt
AC
2 ms
5140 KiB
17.txt
AC
1 ms
3608 KiB
18.txt
AC
2 ms
3676 KiB
19.txt
AC
10 ms
3704 KiB
20.txt
AC
43 ms
7076 KiB
21.txt
AC
46 ms
5704 KiB
22.txt
AC
45 ms
5704 KiB
23.txt
AC
39 ms
8620 KiB
24.txt
AC
51 ms
8652 KiB
25.txt
AC
40 ms
8656 KiB
26.txt
AC
40 ms
8728 KiB
27.txt
AC
40 ms
8656 KiB
28.txt
AC
47 ms
5844 KiB
29.txt
AC
53 ms
8156 KiB
30.txt
AC
42 ms
5736 KiB
31.txt
AC
54 ms
8452 KiB
32.txt
AC
46 ms
5644 KiB
33.txt
AC
53 ms
8620 KiB
34.txt
AC
47 ms
6060 KiB
35.txt
AC
53 ms
8616 KiB
36.txt
AC
42 ms
5624 KiB
37.txt
AC
51 ms
8880 KiB
38.txt
AC
40 ms
5796 KiB
39.txt
AC
51 ms
8712 KiB
40.txt
AC
41 ms
8876 KiB
41.txt
AC
41 ms
8100 KiB
42.txt
AC
39 ms
8844 KiB
43.txt
AC
40 ms
8652 KiB
44.txt
AC
40 ms
8620 KiB
45.txt
AC
40 ms
8652 KiB
46.txt
AC
46 ms
8620 KiB
47.txt
AC
47 ms
8652 KiB
48.txt
AC
46 ms
8616 KiB
49.txt
AC
47 ms
8732 KiB
50.txt
AC
54 ms
8616 KiB
51.txt
AC
54 ms
8620 KiB
52.txt
AC
57 ms
8776 KiB
53.txt
AC
52 ms
8612 KiB
54.txt
AC
52 ms
8616 KiB
55.txt
AC
57 ms
8652 KiB
sample-01.txt
AC
2 ms
3484 KiB
sample-02.txt
AC
2 ms
5796 KiB