結果
問題 | No.1373 Directed Operations |
ユーザー | tada721 |
提出日時 | 2021-02-05 21:47:09 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 171 ms / 2,000 ms |
コード長 | 4,946 bytes |
コンパイル時間 | 1,150 ms |
コンパイル使用メモリ | 100,608 KB |
実行使用メモリ | 7,316 KB |
最終ジャッジ日時 | 2024-07-02 11:58:52 |
合計ジャッジ時間 | 3,800 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 132 ms
6,944 KB |
testcase_03 | AC | 17 ms
6,944 KB |
testcase_04 | AC | 29 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 151 ms
7,272 KB |
testcase_07 | AC | 5 ms
6,940 KB |
testcase_08 | AC | 17 ms
6,944 KB |
testcase_09 | AC | 35 ms
7,316 KB |
testcase_10 | AC | 30 ms
6,940 KB |
testcase_11 | AC | 8 ms
6,940 KB |
testcase_12 | AC | 31 ms
6,944 KB |
testcase_13 | AC | 5 ms
6,944 KB |
testcase_14 | AC | 168 ms
7,036 KB |
testcase_15 | AC | 138 ms
6,940 KB |
testcase_16 | AC | 171 ms
6,992 KB |
testcase_17 | AC | 116 ms
6,944 KB |
testcase_18 | AC | 64 ms
6,940 KB |
testcase_19 | AC | 62 ms
6,944 KB |
testcase_20 | AC | 86 ms
6,940 KB |
コンパイルメッセージ
main.cpp: In function 'long long int keta(long long int)': main.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type] 40 | } | ^ main.cpp: In function 'long long int gcd(long long int, long long int)': main.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type] 54 | } | ^ main.cpp: In function 'long long int lcm(long long int, long long int)': main.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type] 67 | } | ^
ソースコード
#include<iostream> #include<algorithm> #include<cmath> #include<map> #include<stdio.h> #include<vector> #include<queue> #include<math.h> #include<deque> #include<set> #include<tuple> using namespace std; #define ll long long #define int long long #define rep(s,i,n) for(int i=s;i<n;i++) #define c(n) cout<<n<<endl; #define ic(n) int n;cin>>n; #define sc(s) string s;cin>>s; #define mod 998244353 #define inf 100000000000007 #define f first #define s second #define mini(c,a,b) *min_element(c+a,c+b) #define maxi(c,a,b) *max_element(c+a,c+b) #define pi 3.141592653589793238462643383279 #define e_ 2.718281828459045235360287471352 #define P pair<int,int> #define upp(a,n,x) upper_bound(a,a+n,x)-a; #define low(a,n,x) lower_bound(a,a+n,x)-a; #define UF UnionFind #define pb push_back //printf("%.12Lf\n",); int keta(int x) { rep(0, i, 30) { if (x < 10) { return i + 1; } x = x / 10; } } int gcd(int x, int y) { if (x == 0 || y == 0)return x + y; int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return bb; } bb = bb % aa; if (bb == 0) { return aa; } } } int lcm(int x, int y) { int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return x / bb * y; } bb = bb % aa; if (bb == 0) { return x / aa * y; } } } bool prime(int x) { if (x == 1)return false; rep(2, i, sqrt(x) + 1) { if (x % i == 0 && x != i) { return false; } } return true; } /*int max(int a, int b) { if (a >= b)return a; else return b; }*/ string maxst(string s, string t) { int n = s.size(); int m = t.size(); if (n > m)return s; else if (n < m)return t; else { rep(0, i, n) { if (s[i] > t[i])return s; if (s[i] < t[i])return t; } return s; } } /*int min(int a, int b) { if (a >= b)return b; else return a; }*/ int yakuwa(int n) { int sum = 0; rep(1, i, sqrt(n + 1)) { if (n % i == 0)sum += i + n / i; if (i * i == n)sum -= i; } return sum; } int poow(int n,int m){ int pro=1; int nn=n; while(m){ if(m%2==1)pro=pro*nn%mod; m=m/2; nn=nn*nn%mod; } return pro; } int poow2(int n,int m,int modulo){ int pro=1; int nn=n; while(m){ if(m%2==1)pro=pro*nn%modulo; m=m/2; nn=nn*nn%modulo; } return pro; } int inv(int n,int m){ int t=poow(m,mod-2)%mod; return n*t%mod; } int com(int n,int m){ if(n<m)return 0; int bunsi=1,bunbo=1; for(int i=n-m+1;i<=n;i++)bunsi=bunsi*i%mod; for(int i=1;i<=m;i++)bunbo=bunbo*i%mod; return inv(bunsi,bunbo); } int minpow(int x, int y) { int sum = 1; rep(0, i, y)sum *= x; return sum; } int ketawa(int x, int sinsuu) { int sum = 0; rep(0, i, 100)sum += (x % poow(sinsuu, i + 1)) / (poow(sinsuu, i)); return sum; } int sankaku(int a) { return a * (a + 1) / 2; } int sames(int a[1111111], int n) { int ans = 0; rep(0, i, n) { if (a[i] == a[i + 1]) { int j = i; while (a[j + 1] == a[i] && j <= n - 2)j++; ans += sankaku(j - i); i = j; } } return ans; } using Graph = vector<vector<int>>; int oya[214514]; int depth[214514]; int subtreesize[214514]; void dfs(const Graph& G, int v, int p, int d) { depth[v] = d; oya[v] = p; for (auto nv : G[v]) { if (nv == p) continue; // nv が親 p だったらダメ dfs(G, nv, v, d + 1); // d を 1 増やして子ノードへ } subtreesize[v]=1; for(auto c:G[v]){ if(c==p)continue; subtreesize[v]+=subtreesize[c]; } } struct UnionFind { vector<int> par; UnionFind(int n):par(n){ rep(0,i,n)par[i]=i; } int root(int x){ if (par[x]==x)return x; return par[x]=root(par[x]); } void unite(int x,int y){ int rx=root(x); int ry=root(y); if (rx==ry) return; par[rx]=ry; } bool same(int x,int y){ int rx=root(x); int ry=root(y); return rx==ry; } }; int dijkstraa[214514]; void dijkstra(int n,int m,int c[514514],int d[514514],int l[514514],int siten,bool mukou){ vector<P> e[214514]; rep(0,i,m){ e[c[i]].pb(P{l[i],d[i]}); if(mukou)e[d[i]].pb(P{l[i],c[i]}); } rep(0,i,n)dijkstraa[i]=inf; dijkstraa[siten]=0; priority_queue<P,vector<P>,greater<P>>pp; pp.push(P{0,siten}); while(!pp.empty()){ P t=pp.top();pp.pop(); if(t.first!=dijkstraa[t.second])continue; for(auto g:e[t.second]){ if(dijkstraa[g.second]>t.first+g.first){ dijkstraa[g.second]=t.first+g.first; pp.push(P{dijkstraa[g.second],g.second}); } } } } int dijkstra2(int shuten){ return dijkstraa[shuten]; } vector<int> toposo(vector<vector<int>> G,vector<int> indegree,int n){ vector<int> sorted_vertices; queue<int> que; rep(0,i,n)if(!indegree[i])que.push(i); while(!que.empty()){ int v=que.front(); que.pop(); rep(0,i,G[v].size()){ int u=G[v][i]; indegree[u]-=1; if(!indegree[u])que.push(u); } sorted_vertices.pb(v); } return sorted_vertices; } P a[114514]; int ans[114514]; signed main(){ ic(n) rep(0,i,n-1){ cin>>a[i].f; a[i].s=i; } sort(a,a+n-1); rep(0,i,n-1){ if(i+1<a[i].f){ c("NO") return 0; } ans[a[i].s]=i+2-a[i].f; } c("YES") rep(0,i,n-1)c(ans[i]) }