Submission #423390

# Submission time Handle Problem Language Result Execution time Memory
423390 2021-06-11T04:53:28 Z juggernaut Furniture (JOI20_furniture) C++17
5 / 100
5000 ms 4184 KB
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
typedef long long ll;
#define USING_ORDERED_SET 0
#if USING_ORDERED_SET
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#endif
template<class T>void umax(T &a,T b){if(a<b)a=b;}
template<class T>void umin(T &a,T b){if(b<a)a=b;}
#ifdef IOI2021SG
    #define printl(args...)printf(args)
#else
    #define printl(args...)((void)0)
#endif
int n,m;
bool a[1005][1005],dp[1005][1005];
bool go(){
    dp[1][1]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)if(i!=1||j!=1)dp[i][j]=(a[i][j]^1)&(dp[i-1][j]|dp[i][j-1]);
    return dp[n][m];
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++){
        int x;
        scanf("%d",&x);
        a[i][j]=x;
    }
    int q;
    scanf("%d",&q);
    while(q--){
        int x,y;
        scanf("%d%d",&x,&y);
        a[x][y]=1;
        if(go())puts("1");
        else{
            puts("0");
            a[x][y]=0;
        }
    }
}

Compilation message

furniture.cpp: In function 'void usaco(std::string)':
furniture.cpp:5:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
furniture.cpp:5:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
furniture.cpp: In function 'int main()':
furniture.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
furniture.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~
furniture.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
furniture.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 332 KB Output is correct
2 Correct 47 ms 460 KB Output is correct
3 Correct 107 ms 468 KB Output is correct
4 Correct 252 ms 472 KB Output is correct
5 Correct 266 ms 488 KB Output is correct
6 Correct 338 ms 488 KB Output is correct
7 Correct 357 ms 476 KB Output is correct
8 Correct 361 ms 492 KB Output is correct
9 Correct 339 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 332 KB Output is correct
2 Correct 47 ms 460 KB Output is correct
3 Correct 107 ms 468 KB Output is correct
4 Correct 252 ms 472 KB Output is correct
5 Correct 266 ms 488 KB Output is correct
6 Correct 338 ms 488 KB Output is correct
7 Correct 357 ms 476 KB Output is correct
8 Correct 361 ms 492 KB Output is correct
9 Correct 339 ms 608 KB Output is correct
10 Correct 4449 ms 556 KB Output is correct
11 Correct 198 ms 332 KB Output is correct
12 Execution timed out 5055 ms 4184 KB Time limit exceeded
13 Halted 0 ms 0 KB -