usingnamespace std; vector<int>h[210000]; intmain() { int n, q; cin >> n >> q; for (int i = 1; i <= n; i++) { int a; cin >> a; for (int j = 1; j <= a; j++) { int s; cin >>s; h[i].push_back(s);
}
} while (q--) { int x, y; cin >> x >> y; cout << h[x][y- 1]<<'\n'; }
#include<iostream> #include<math.h> usingnamespace std; intmain() { int x, y, z; cin >> x >> y >> z; if (x * y < 0) { cout << abs(x); } if (x * y > 0&&x>0&&y>0&&x<y) { cout << x;
} if (x * y > 0 && x > 0 && y > 0 && x > y&&z>y) { cout << -1;
} if (x * y > 0 && x > 0 && y > 0 && x > y && z < y&&z>0) { cout << x;
} if (x * y > 0 && x > 0 && y > 0 && x > y && z < y&&z<0) { cout << 2*abs(z)+abs(x);
} if (x * y > 0 && x < 0 && y < 0 && x > y) { cout << x;
} if (x * y < 0 && x < 0 && y < 0 && x < y && z < y) { cout << -1;
} if (x * y > 0 && x < 0 && y < 0 && x < y && z > y && z<0) { cout << x;
} if (x * y > 0 && x < 0 && y < 0 && x < y && z > y && z > 0) { cout << 2 * abs(z) + abs(x);
#include<iostream> #include<queue> usingnamespace std; vector<int>g[200000]; vector<int>s[300000]; int n; queue<int>q; int vis[300000]; int r; boolbfs(int x) { q.push(x); vis[x] = 1;
while (!q.empty()) { int t = q.front(); q.pop(); s[t].push_back(t); for (int i = 0; i < g[t].size(); i++) { if (!vis[g[t][i]]) { vis[g[t][i]] = 1; q.push(g[t][i]); s[g[t][i]].push_back(t);
} if (g[t][i] == r) {
return1;
}
} }
return0;
} int m; int flag=0; voidprint(int r) { if(flag) { return ; } if(r==m) { flag=1; return ; }
print(s[r][0]) ; cout<<s[r][0]<<' '; }
intmain(){ cin >> n;
cin >> m;
cin >> r; for (int i = 1; i <= n - 1; i++) { int x, y; cin >> x >> y; g[x].push_back(y); g[y].push_back(x);