Submission #1013376

#TimeUsernameProblemLanguageResultExecution timeMemory
10133768pete8Sprinkler (JOI22_sprinkler)C++17
3 / 100
4066 ms26192 KiB
#include<iostream> #include<stack> #include<map> #include<vector> #include<string> #include<cassert> #include<unordered_map> #include <queue> #include <cstdint> #include<cstring> #include<limits.h> #include<cmath> #include<set> #include<algorithm> #include <iomanip> #include<numeric> #include<bitset> using namespace std; #define ll long long #define f first #define s second #define pii pair<int,int> #define ppii pair<int,pii> #define vi vector<int> #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define F(n) for(int i=0;i<n;i++) #define lb lower_bound #define ub upper_bound #define fastio ios::sync_with_stdio(false);cin.tie(NULL); #pragma GCC optimize ("03,unroll-lopps") #define int long long using namespace std; const int mod=1e9+7,mxn=2e5+5,inf=1e18,minf=-1e18,lg=30; //#undef int int n,k,m; vector<int>adj[mxn+10]; void setIO(string name){ ios_base::sync_with_stdio(0); cin.tie(0); freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } int h[mxn+10],dist[mxn+10]; void solve(int x,int d,int w){ stack<int>st; queue<int>q; q.push(x); dist[x]=0; while(!q.empty()){ int cur=q.front(); q.pop(); h[cur]=(h[cur]%k*w%k)%k; st.push(cur); for(auto i:adj[cur])if(dist[i]==-1&&dist[cur]+1<=d)dist[i]=dist[cur]+1,q.push(i); } while(!st.empty())dist[st.top()]=-1,st.pop(); } int32_t main(){ fastio cin>>n>>k; for(int i=1;i<=n;i++)dist[i]=-1; for(int i=0;i<n-1;i++){ int a,b;cin>>a>>b; adj[a].pb(b); adj[b].pb(a); } for(int i=1;i<=n;i++)cin>>h[i]; int q;cin>>q; while(q--){ int x;cin>>x; if(x==1){ int a,b,c;cin>>a>>b>>c; solve(a,b,c); } else{ int a;cin>>a; cout<<h[a]<<'\n'; } } } /* 4 7 1 2 2 3 3 4 1 1 1 1 11 1 2 1 2 1 1 0 2 2 1 2 2 2 3 2 4 1 4 10 2 2 1 2 2 2 3 2 4 */

Compilation message (stderr)

sprinkler.cpp:32:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
   32 | #pragma GCC optimize ("03,unroll-lopps")
      |                                        ^
sprinkler.cpp:39:23: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   39 | void setIO(string name){
      |                       ^
sprinkler.cpp:45:29: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   45 | void solve(int x,int d,int w){
      |                             ^
sprinkler.cpp:59:14: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   59 | int32_t main(){
      |              ^
sprinkler.cpp: In function 'void setIO(std::string)':
sprinkler.cpp:41:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sprinkler.cpp:42:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...