Submission #968272

#TimeUsernameProblemLanguageResultExecution timeMemory
968272IsamSuperpozicija (COCI22_superpozicija)C++17
10 / 110
16 ms3128 KiB
#include<bits/stdc++.h> using namespace std; int n, a[100002], b[100002]; string z; inline bool is_valid(string s){ int tot(0); for(register int i = 0; i < (int)s.size(); ++i){ tot += (s[i]=='('?1:-1); if(tot < 0) return false; } return !tot; } int ans[100002]; signed main(){ ios_base::sync_with_stdio(0), cin.tie(0); int T; cin >> T; function<void()> test_case = [](){ cin >> n >> z; z = '.' + z; string tmp = ""; for(register int i = 1; i <= n; ++i){ cin >> a[i] >> b[i]; if(z[a[i]] == '('){ z[b[i]] = '.'; ans[i] = 0; }else{ z[a[i]] = '.'; ans[i] = 1; } } if(n & 1) return cout << -1 << '\n', void(); for(register int i = 1; i <= n*2; ++i){ if(z[i] == '.') continue; tmp += z[i]; } if(is_valid(tmp)){ for(register int i = 1; i <= n; ++i) cout << ans[i] << ' '; }else{ cout << -1; } cout << '\n'; }; while(T--) test_case(); return 0; }

Compilation message (stderr)

Main.cpp: In function 'bool is_valid(std::string)':
Main.cpp:11:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   11 |  for(register int i = 0; i < (int)s.size(); ++i){
      |                   ^
Main.cpp: In lambda function:
Main.cpp:32:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |   for(register int i = 1; i <= n; ++i){
      |                    ^
Main.cpp:44:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   44 |   for(register int i = 1; i <= n*2; ++i){
      |                    ^
Main.cpp:50:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   50 |    for(register int i = 1; i <= n; ++i) cout << ans[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...