提出 #75069564
ソースコード 拡げる
#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 (int 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 target("sse,sse2,sse3,ssse3,sse4,abm,mmx,tune=native")
std::vector<int> prefix_function(const std::string &s) {
int n = s.size();
std::vector<int> pi(n);
for (int i = 1; i < n; ++i) {
int j = pi[i - 1];
while (j > 0 && s[i] != s[j])
j = pi[j - 1];
if (s[i] == s[j]) ++j;
pi[i] = j;
}
return pi;
}
void solve() {
int n, m;
cin >> n >> m;
vector<vector<int>> gr(n);
fori(m) {
int a, b;
cin >> a >> b;
a--;b--;
gr[a].push_back(b);
}
set<int> ans;
queue<int> q;
q.push(0);
ans.insert(0);
while (!q.empty()) {
int z = q.front();
q.pop();
int sz = gr[z].size();
fori(sz) {
int zz = gr[z][i];
int sss = ans.size();
ans.insert(zz);
if (sss != ans.size()) {
q.push(zz);
}
}
}
cout << ans.size() << "\n";
}
int main() {
ffast_io;
solve();
return 0;
}
提出情報
コンパイルエラー
./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:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | #define fori(n)for (int 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;
| ^~~
./Main.cpp: In function 'void solve()':
./Main.cpp:138:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
138 | if (sss != ans.size()) {
| ~~~~^~~~~~~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
300 / 300 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 03_killer_00.txt, 03_killer_01.txt, 03_killer_02.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_00.txt |
AC |
1 ms |
3600 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3532 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3620 KiB |
| 01_handmade_00.txt |
AC |
14 ms |
5432 KiB |
| 01_handmade_01.txt |
AC |
16 ms |
5412 KiB |
| 01_handmade_02.txt |
AC |
16 ms |
5132 KiB |
| 01_handmade_03.txt |
AC |
27 ms |
5808 KiB |
| 01_handmade_04.txt |
AC |
28 ms |
5568 KiB |
| 01_handmade_05.txt |
AC |
163 ms |
33708 KiB |
| 01_handmade_06.txt |
AC |
155 ms |
33872 KiB |
| 01_handmade_07.txt |
AC |
87 ms |
18516 KiB |
| 01_handmade_08.txt |
AC |
87 ms |
18508 KiB |
| 01_handmade_09.txt |
AC |
32 ms |
13252 KiB |
| 02_random_00.txt |
AC |
48 ms |
16744 KiB |
| 02_random_01.txt |
AC |
49 ms |
7416 KiB |
| 02_random_02.txt |
AC |
23 ms |
4968 KiB |
| 02_random_03.txt |
AC |
56 ms |
7688 KiB |
| 02_random_04.txt |
AC |
36 ms |
5328 KiB |
| 02_random_05.txt |
AC |
20 ms |
5584 KiB |
| 03_killer_00.txt |
AC |
51 ms |
23840 KiB |
| 03_killer_01.txt |
AC |
54 ms |
23936 KiB |
| 03_killer_02.txt |
AC |
67 ms |
27900 KiB |