結果

問題 No.1401 全自動マクロの作り方
ユーザー chocorusk
提出日時 2021-02-24 09:38:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,410 bytes
コンパイル時間 1,256 ms
コンパイル使用メモリ 129,668 KB
最終ジャッジ日時 2025-01-19 04:18:24
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:40:9: warning: ‘a’ may be used uninitialized [-Wmaybe-uninitialized]
   40 |         if(a==b) continue;
      |         ^~
main.cpp:34:13: note: ‘a’ was declared here
   34 |         int a, b;
      |             ^

ソースコード

diff #
プレゼンテーションモードにする

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <stack>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
int n; cin>>n;
vector<int> g[2020];
int deg[2020]={};
for(int i=0; i<n; i++){
int d; cin>>d;
int a, b;
for(int j=0; j<d; j++){
int s; cin>>s;
if(j==0) a=s;
if(j==d-1) b=s;
}
if(a==b) continue;
a--; b--;
g[a].push_back(b);
deg[b]++;
}
const int N=2000;
queue<int> que;
for(int i=0; i<N; i++){
if(deg[i]==0) que.push(i);
}
vector<int> ans;
while(!que.empty()){
int x=que.front(); que.pop();
ans.push_back(x);
for(auto y:g[x]){
deg[y]--;
if(deg[y]==0) que.push(y);
}
}
if(ans.size()<N) cout<<0<<endl;
else{
cout<<N<<endl;
for(int i=0; i<N; i++){
cout<<ans[i]+1;
if(i<N-1) cout<<" ";
}
cout<<endl;
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0