Submission #402134

#TimeUsernameProblemLanguageResultExecution timeMemory
402134AriaHLong Mansion (JOI17_long_mansion)C++11
5 / 100
3062 ms19144 KiB
/** I can do this all day **/ #pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define all(x) (x).begin(),(x).end() #define F first #define S second #define Mp make_pair #define SZ(x) (int)x.size() #define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define file_io freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout); const int N = 5e5 + 10; const ll mod = 1e9 + 7; const ll mod2 = 998244353; const ll inf = 1e9; const int LOG = 22; ll pw(ll a , ll b, ll M) { return (!b ? 1 : (b & 1 ? (a * pw(a * a % M, b / 2, M)) % M : pw(a * a % M, b / 2, M))); } int n, q, X[N], Y[N], C[N], Z[N], mark[N]; vector < int > keys[N]; int main() { scanf("%d", &n); for(int i = 1; i < n; i ++) { scanf("%d", &C[i]); } for(int i = 1; i <= n; i ++) { scanf("%d", &Z[i]); for(int j = 1; j <= Z[i]; j ++) { int x; scanf("%d", &x); keys[i].push_back(x); } } scanf("%d", &q); for(int i = 1; i <= q; i ++) { scanf("%d%d", &X[i], &Y[i]); memset(mark, 0, sizeof mark); int l = X[i], r = X[i]; for(auto x : keys[X[i]]) mark[x] = 1; while(1) { if(!mark[C[l - 1]] && !mark[C[r]]) break; if(mark[C[l - 1]]) { l --; for(auto x : keys[l]) mark[x] = 1; } else { r ++; for(auto x : keys[r]) mark[x] = 1; } } if(l <= Y[i] && Y[i] <= r) { printf("YES\n"); } else { printf("NO\n"); } } return 0; }

Compilation message (stderr)

long_mansion.cpp: In function 'int main()':
long_mansion.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
long_mansion.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   scanf("%d", &C[i]);
      |   ~~~~~^~~~~~~~~~~~~
long_mansion.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |   scanf("%d", &Z[i]);
      |   ~~~~~^~~~~~~~~~~~~
long_mansion.cpp:44:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |    scanf("%d", &x);
      |    ~~~~~^~~~~~~~~~
long_mansion.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
long_mansion.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |   scanf("%d%d", &X[i], &Y[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...