# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
727389 | 2023-04-20T14:41:39 Z | Augustyn | Superpozicija (COCI22_superpozicija) | C++17 | 23 ms | 4012 KB |
#include<iostream> #include<vector> #include<queue> #include<set> using namespace std; char *naw; vector<pair<int,int>>ab; vector<int>juzwyb,gdziedr; int t,n; void rozw() { scanf("%d",&n); priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>prikol; priority_queue<pair<int,int>,vector<pair<int,int>>,less<pair<int,int>>>prikol_less; delete[] naw; naw = new char[n<<1]; ab.resize(n); juzwyb.resize(n<<1); gdziedr.resize(n<<1); scanf("%s",naw); for(int i=0;i<n;++i) { scanf("%d%d",&ab[i].first,&ab[i].second); --ab[i].first; --ab[i].second; gdziedr[ab[i].first]=ab[i].second; gdziedr[ab[i].second]=ab[i].first; } int ile=0; for(int i=0;i<2*n;++i) { if(naw[gdziedr[i]]==naw[i]) { if(naw[i]=='('&&i<gdziedr[i]) { juzwyb[i]=t; juzwyb[gdziedr[i]]=-t; ++ile; } else if(naw[i]==')'&&i>gdziedr[i]) { juzwyb[i]=t; juzwyb[gdziedr[i]]=-t; --ile; } } else { if(juzwyb[i]==t) { if(naw[i]==')') --ile; else ++ile; } else if(juzwyb[i]!=-t) { if(naw[i]=='(') { juzwyb[i]=-t; juzwyb[gdziedr[i]]=t; prikol.push({i,gdziedr[i]}); } else { juzwyb[i]=t; juzwyb[gdziedr[i]]=-t; --ile; prikol.push({gdziedr[i],i}); } } } if(ile<0) { if(prikol.empty()) { printf("-1\n"); return; } if(prikol.top().first<i) ++ile; ++ile; juzwyb[prikol.top().first]=t; juzwyb[prikol.top().second]=-t; prikol.pop(); } } if(ile!=0) { printf("-1\n"); return; } for(int i=0;i<n;++i) { if(juzwyb[ab[i].first]==t) printf("0 "); else printf("1 "); } printf("\n"); } int main() { scanf("%d",&t); while(t) { rozw(); --t; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 984 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 1192 KB | Output is correct |
2 | Correct | 19 ms | 1700 KB | Output is correct |
3 | Correct | 17 ms | 1868 KB | Output is correct |
4 | Correct | 19 ms | 2220 KB | Output is correct |
5 | Correct | 17 ms | 2388 KB | Output is correct |
6 | Correct | 11 ms | 2260 KB | Output is correct |
7 | Correct | 15 ms | 2644 KB | Output is correct |
8 | Correct | 16 ms | 3028 KB | Output is correct |
9 | Correct | 19 ms | 3492 KB | Output is correct |
10 | Correct | 21 ms | 3788 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 21 ms | 1236 KB | Output is correct |
3 | Correct | 19 ms | 1816 KB | Output is correct |
4 | Correct | 20 ms | 1968 KB | Output is correct |
5 | Correct | 20 ms | 2512 KB | Output is correct |
6 | Runtime error | 20 ms | 4012 KB | Execution killed with signal 6 |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 984 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |