Submission #550795

# Submission time Handle Problem Language Result Execution time Memory
550795 2022-04-19T08:26:16 Z Killer2501 Zagrade (COI20_zagrade) C++14
100 / 100
889 ms 15132 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pll pair<int, pii>
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
const int N = 2e5+5;
const int M = 350;
const int mod = 1e9+7;
const ll base = 75;
const ll inf = 1e12;
int n, t, tong;
int k, m, a[N], b[N], c[N];
ll ans, dp[N], d[N];
vector<int> adj[N], gr[N];
vector<int> g[N], vi;
void sol()
{
    cin >> n >> t;
    vi.pb(1);
    m = n/2;
    for(int i = 2; i <= n; i ++)
    {
        if(vi.empty())vi.pb(i);
        else
        {
            cout <<"? "<< vi.back() <<" "<<i<<endl;
            cin >> k;
            if(k)
            {
                a[vi.back()] = 1;
                a[i] = 2;
                --m;
                vi.pop_back();
            }
            else vi.pb(i);
        }
    }
    cout << "! ";
    for(int i = 1; i <= n; i ++)
    {
        if(a[i] == 1)cout << '(';
        else if(a[i] == 2)cout << ')';
        else
        {
            if(m > 0)
            {
                cout << ')';
                --m;
            }
            else cout << '(';
        }
    }
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    #define task "tests"
    if(fopen(task".inp", "r"))
	{
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
	}
    int test = 1;
    //cin >> test;
    while(test -- > 0)sol();
    return 0;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:67:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
zagrade.cpp:68:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14416 KB Output is correct
2 Correct 10 ms 14412 KB Output is correct
3 Correct 22 ms 14412 KB Output is correct
4 Correct 15 ms 14416 KB Output is correct
5 Correct 22 ms 14384 KB Output is correct
6 Correct 11 ms 14288 KB Output is correct
7 Correct 21 ms 14416 KB Output is correct
8 Correct 17 ms 14416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14416 KB Output is correct
2 Correct 16 ms 14420 KB Output is correct
3 Correct 13 ms 14416 KB Output is correct
4 Correct 16 ms 14348 KB Output is correct
5 Correct 16 ms 14416 KB Output is correct
6 Correct 15 ms 14416 KB Output is correct
7 Correct 17 ms 14416 KB Output is correct
8 Correct 16 ms 14420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14288 KB Output is correct
2 Correct 352 ms 14780 KB Output is correct
3 Correct 690 ms 14872 KB Output is correct
4 Correct 882 ms 14768 KB Output is correct
5 Correct 714 ms 14780 KB Output is correct
6 Correct 798 ms 14896 KB Output is correct
7 Correct 825 ms 15132 KB Output is correct
8 Correct 790 ms 14908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 749 ms 15052 KB Output is correct
3 Correct 861 ms 14996 KB Output is correct
4 Correct 697 ms 15124 KB Output is correct
5 Correct 772 ms 14984 KB Output is correct
6 Correct 889 ms 15124 KB Output is correct
7 Correct 863 ms 15040 KB Output is correct
8 Correct 572 ms 14792 KB Output is correct