Submission #730737

#TimeUsernameProblemLanguageResultExecution timeMemory
730737AugustynSuperpozicija (COCI22_superpozicija)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define f first #define s second #define pf printf #define pi pair<int,int> pi a[200001]; char w[200001]; int b[200001],g[200001]; int t,n; int main() { scanf("%d",&t); while(t) { scanf("%d",&n); priority_queue<pi,vector<pi>,greater<pi>>d; getchar(); for(int i=0;i<n*2;++i)w[i]=getchar(); for(int i=0;i<n;++i) { scanf("%d%d",&a[i].f,&a[i].s); --a[i].f; --a[i].s; g[a[i].f]=a[i].s; g[a[i].s]=a[i].f; } int e=0; for(int i=0;i<2*n;++i) { if(w[g[i]]==w[i]) { if(w[i]=='('&&i<g[i]) { b[i]=t; b[g[i]]=-t; ++e; } else if(w[i]==')'&&i>g[i]) { b[i]=t; b[g[i]]=-t; --e; } } else if(b[i]!=-t&&b[i]!=t) { if(w[i]=='(') { b[i]=-t; b[g[i]]=t; d.push({g[i],i}); } else { b[i]=t; b[g[i]]=-t; --e; d.push({g[i],i}); } } else if(b[i]==t) { e++; if(w[i]==')') e-=2; } if(e<0) { if(d.empty()) { pf("-1\n"); return; } b[d.top().s]*=-1; b[d.top().f]*=-1; ++e; if(max(d.top().f,d.top().s)<=i) ++e; d.pop(); } } if(e!=0) { pf("-1\n"); return; } for(int i=0;i<n;++i) if(b[a[i].f]==t)pf("0 "); else pf("1 "); pf("\n"); --t; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:73:1: error: return-statement with no value, in function returning 'int' [-fpermissive]
   73 | return;
      | ^~~~~~
Main.cpp:86:1: error: return-statement with no value, in function returning 'int' [-fpermissive]
   86 | return;
      | ^~~~~~
Main.cpp:13:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | scanf("%d",&t);
      | ~~~~~^~~~~~~~~
Main.cpp:16:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | scanf("%d",&n);
      | ~~~~~^~~~~~~~~
Main.cpp:22:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 | scanf("%d%d",&a[i].f,&a[i].s);
      | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~